Then what's really happening is TWO different sections of memory are being allocated. It's done at one time, but it's two "logical" blocks. One is the int which stores the actual value, and the other is the control block, which stores all the
shared_ptr<T>::operator->返回的是T*类型指针,非const T*指针.因此通过const shared_ptr<T>&类型的ptr可以直接调用T各个原始的方法,不用担心const与非const问题.具体shared_ptr::operator->实现如下,摘自boost1.52.0版本boost\smart_ptr\shared_ptr.hpp T * operator-> () const // never throws { B
Defined in header <memory> template< class T > class shared_ptr; (since C++11) std::shared_ptr is a smart pointer that retains shared ownership of an object through a pointer. Severalshared_ptr objects may own the same object; the ob