std::shared_ptr
std::shared_ptr
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. Several shared_ptr
objects may own the same object. The object is destroyed and its memory deallocated when either of the following happens:
- the last remaining
shared_ptr
owning the object is destroyed; - the last remaining
shared_ptr
owning the object is assigned another pointer via登录查看完整内容