.TH "std::shared_ptr< _Tp >" 3 "libstdc++" \" -*- nroff -*- .ad l .nh .SH NAME std::shared_ptr< _Tp > \- A smart pointer with reference-counted copy semantics\&. .SH SYNOPSIS .br .PP .PP \fR#include \fP .PP Inherits std::__shared_ptr< _Tp, _Lp >\&. .SS "Public Types" .in +1c .ti -1c .RI "\fBusing\fP \fBelement_type\fP" .br .RI "The type pointed to by the stored pointer, remove_extent_t<_Tp> " .ti -1c .RI "\fBusing\fP \fBweak_type\fP" .br .RI "The corresponding weak_ptr type for this shared_ptr\&. " .in -1c .SS "Public Member Functions" .in +1c .ti -1c .RI "\fBconstexpr\fP \fBshared_ptr\fP () noexcept" .br .RI "Construct an empty shared_ptr\&. " .ti -1c .RI "template> \fBshared_ptr\fP (\fB_Yp\fP *__p)" .br .RI "Construct a shared_ptr that owns the pointer \fI__p\fP\&. " .ti -1c .RI "template> \fBshared_ptr\fP (\fB_Yp\fP *__p, \fB_Deleter\fP __d)" .br .RI "Construct a shared_ptr that owns the pointer \fI__p\fP and the deleter \fI__d\fP\&. " .ti -1c .RI "template> \fBshared_ptr\fP (\fB_Yp\fP *__p, \fB_Deleter\fP __d, _Alloc __a)" .br .RI "Construct a shared_ptr that owns the pointer \fI__p\fP and the deleter \fI__d\fP\&. " .ti -1c .RI "template>> \fBshared_ptr\fP (\fBauto_ptr\fP< \fB_Yp\fP > &&__r)" .br .ti -1c .RI "\fBshared_ptr\fP (\fBconst\fP \fBshared_ptr\fP &) noexcept=\fBdefault\fP" .br .RI "Copy constructor\&. " .ti -1c .RI "template&>> \fBshared_ptr\fP (\fBconst\fP \fBshared_ptr\fP< \fB_Yp\fP > &__r) noexcept" .br .RI "If \fI__r\fP is empty, constructs an empty shared_ptr; otherwise construct a shared_ptr that shares ownership with \fI__r\fP\&. " .ti -1c .RI "template \fBshared_ptr\fP (\fBconst\fP \fBshared_ptr\fP< \fB_Yp\fP > &__r, \fBelement_type\fP *__p) noexcept" .br .RI "Constructs a \fRshared_ptr\fP instance that stores \fR__p\fP and shares ownership with \fR__r\fP\&. " .ti -1c .RI "template&>> \fBshared_ptr\fP (\fBconst\fP \fBweak_ptr\fP< \fB_Yp\fP > &__r)" .br .RI "Constructs a shared_ptr that shares ownership with \fI__r\fP and stores a copy of the pointer stored in \fI__r\fP\&. " .ti -1c .RI "template \fBshared_ptr\fP (nullptr_t __p, \fB_Deleter\fP __d)" .br .RI "Construct a shared_ptr that owns a null pointer and the deleter \fI__d\fP\&. " .ti -1c .RI "template \fBshared_ptr\fP (nullptr_t __p, \fB_Deleter\fP __d, _Alloc __a)" .br .RI "Construct a shared_ptr that owns a null pointer and the deleter \fI__d\fP\&. " .ti -1c .RI "\fBconstexpr\fP \fBshared_ptr\fP (nullptr_t) noexcept" .br .RI "Construct an empty shared_ptr\&. " .ti -1c .RI "\fBshared_ptr\fP (\fBshared_ptr\fP &&__r) noexcept" .br .RI "Move-constructs a shared_ptr instance from \fI__r\fP\&. " .ti -1c .RI "template>> \fBshared_ptr\fP (\fBshared_ptr\fP< \fB_Yp\fP > &&__r) noexcept" .br .RI "Move-constructs a shared_ptr instance from \fI__r\fP\&. " .ti -1c .RI "template \fBshared_ptr\fP (\fBshared_ptr\fP< \fB_Yp\fP > &&__r, \fBelement_type\fP *__p) noexcept" .br .RI "Constructs a \fRshared_ptr\fP instance that stores \fR__p\fP and shares ownership with \fR__r\fP\&. " .ti -1c .RI "template \fBshared_ptr\fP (\fBstd::auto_ptr\fP< \fB_Tp1\fP > &&__r)" .br .ti -1c .RI "template>> \fBshared_ptr\fP (\fBunique_ptr\fP< \fB_Yp\fP, \fB_Del\fP > &&__r)" .br .ti -1c .RI "\fBelement_type\fP * \fBget\fP () \fBconst\fP noexcept" .br .RI "Return the stored pointer\&. " .ti -1c .RI "\fBoperator bool\fP () \fBconst\fP noexcept" .br .RI "Return true if the stored pointer is not null\&. " .ti -1c .RI "\fBelement_type\fP & \fBoperator*\fP () \fBconst\fP noexcept" .br .ti -1c .RI "\fBelement_type\fP * \fBoperator\->\fP () \fBconst\fP noexcept" .br .ti -1c .RI "template _Assignable< \fBauto_ptr\fP< \fB_Yp\fP > > \fBoperator=\fP (\fBauto_ptr\fP< \fB_Yp\fP > &&__r)" .br .ti -1c .RI "\fBshared_ptr\fP & \fBoperator=\fP (\fBconst\fP \fBshared_ptr\fP &) noexcept=\fBdefault\fP" .br .ti -1c .RI "template _Assignable< \fBconst\fP \fBshared_ptr\fP< \fB_Yp\fP > & > \fBoperator=\fP (\fBconst\fP \fBshared_ptr\fP< \fB_Yp\fP > &__r) noexcept" .br .ti -1c .RI "\fBshared_ptr\fP & \fBoperator=\fP (\fBshared_ptr\fP &&__r) noexcept" .br .ti -1c .RI "template<\fBclass\fP \fB_Yp\fP > _Assignable< \fBshared_ptr\fP< \fB_Yp\fP > > \fBoperator=\fP (\fBshared_ptr\fP< \fB_Yp\fP > &&__r) noexcept" .br .ti -1c .RI "template _Assignable< \fBunique_ptr\fP< \fB_Yp\fP, \fB_Del\fP > > \fBoperator=\fP (\fBunique_ptr\fP< \fB_Yp\fP, \fB_Del\fP > &&__r)" .br .ti -1c .RI "\fBvoid\fP \fBreset\fP () noexcept" .br .ti -1c .RI "template _SafeConv< \fB_Yp\fP > \fBreset\fP (\fB_Yp\fP *__p)" .br .ti -1c .RI "template _SafeConv< \fB_Yp\fP > \fBreset\fP (\fB_Yp\fP *__p, \fB_Deleter\fP __d)" .br .ti -1c .RI "template _SafeConv< \fB_Yp\fP > \fBreset\fP (\fB_Yp\fP *__p, \fB_Deleter\fP __d, _Alloc __a)" .br .ti -1c .RI "\fBvoid\fP \fBswap\fP (__shared_ptr< _Tp, \fB_Lp\fP > &__other) noexcept" .br .RI "Exchange both the owned pointer and the stored pointer\&. " .ti -1c .RI "bool \fBunique\fP () \fBconst\fP noexcept" .br .RI "Return true if use_count() == 1\&. " .ti -1c .RI "long \fBuse_count\fP () \fBconst\fP noexcept" .br .RI "If *this owns a pointer, return the number of owners, otherwise zero\&. " .in -1c .PP .RI "\fB\fP" .br .in +1c .in +1c .ti -1c .RI "template bool \fBowner_before\fP (__shared_ptr< \fB_Tp1\fP, \fB_Lp\fP > \fBconst\fP &\fB__rhs\fP) \fBconst\fP noexcept" .br .RI "Define an ordering based on ownership\&. " .ti -1c .RI "template bool \fBowner_before\fP (__weak_ptr< \fB_Tp1\fP, \fB_Lp\fP > \fBconst\fP &\fB__rhs\fP) \fBconst\fP noexcept" .br .RI "Define an ordering based on ownership\&. " .in -1c .in -1c .SS "Friends" .in +1c .ti -1c .RI "template \fBshared_ptr\fP< \fB_BoundedArray\fP< \fB_Yp\fP > > \fBallocate_shared\fP (\fBconst\fP _Alloc &)" .br .ti -1c .RI "template \fBshared_ptr\fP< \fB_NonArray\fP< \fB_Yp\fP > > \fBallocate_shared\fP (\fBconst\fP _Alloc &, \fB_Args\fP &&\&.\&.\&.)" .br .ti -1c .RI "template \fBshared_ptr\fP< \fB_BoundedArray\fP< \fB_Yp\fP > > \fBallocate_shared\fP (\fBconst\fP _Alloc &, \fBconst\fP \fBremove_extent_t\fP< \fB_Yp\fP > &)" .br .ti -1c .RI "template \fBshared_ptr\fP< \fB_UnboundedArray\fP< \fB_Yp\fP > > \fBallocate_shared\fP (\fBconst\fP _Alloc &, size_t)" .br .ti -1c .RI "template \fBshared_ptr\fP< \fB_UnboundedArray\fP< \fB_Yp\fP > > \fBallocate_shared\fP (\fBconst\fP _Alloc &, size_t, \fBconst\fP \fBremove_extent_t\fP< \fB_Yp\fP > &)" .br .ti -1c .RI "template \fBshared_ptr\fP< \fB_NotUnboundedArray\fP< \fB_Yp\fP > > \fBallocate_shared_for_overwrite\fP (\fBconst\fP _Alloc &)" .br .ti -1c .RI "template \fBshared_ptr\fP< \fB_UnboundedArray\fP< \fB_Yp\fP > > \fBallocate_shared_for_overwrite\fP (\fBconst\fP _Alloc &, size_t)" .br .ti -1c .RI "template \fBshared_ptr\fP< \fB_BoundedArray\fP< \fB_Yp\fP > > \fBmake_shared\fP ()" .br .ti -1c .RI "template \fBshared_ptr\fP< \fB_NonArray\fP< \fB_Yp\fP > > \fBmake_shared\fP (\fB_Args\fP &&\&.\&.\&.)" .br .ti -1c .RI "template \fBshared_ptr\fP< \fB_BoundedArray\fP< \fB_Yp\fP > > \fBmake_shared\fP (\fBconst\fP \fBremove_extent_t\fP< \fB_Yp\fP > &)" .br .ti -1c .RI "template \fBshared_ptr\fP< \fB_UnboundedArray\fP< \fB_Yp\fP > > \fBmake_shared\fP (size_t)" .br .ti -1c .RI "template \fBshared_ptr\fP< \fB_UnboundedArray\fP< \fB_Yp\fP > > \fBmake_shared\fP (size_t, \fBconst\fP \fBremove_extent_t\fP< \fB_Yp\fP > &)" .br .ti -1c .RI "template \fBshared_ptr\fP< \fB_NotUnboundedArray\fP< \fB_Yp\fP > > \fBmake_shared_for_overwrite\fP ()" .br .ti -1c .RI "template \fBshared_ptr\fP< \fB_UnboundedArray\fP< \fB_Yp\fP > > \fBmake_shared_for_overwrite\fP (size_t)" .br .ti -1c .RI "\fBclass\fP \fBweak_ptr< _Tp >\fP" .br .in -1c .SS "Related Symbols" (Note that these are not member symbols\&.) .in +1c .ti -1c .RI "template \fB_Del\fP * \fBget_deleter\fP (\fBconst\fP \fBshared_ptr\fP< _Tp > &__p) noexcept" .br .RI "20\&.7\&.2\&.2\&.10 shared_ptr get_deleter " .ti -1c .RI "template \fBstd::basic_ostream\fP< \fB_Ch\fP, \fB_Tr\fP > & \fBoperator<<\fP (\fBstd::basic_ostream\fP< \fB_Ch\fP, \fB_Tr\fP > &\fB__os\fP, \fBconst\fP __shared_ptr< _Tp, \fB_Lp\fP > &__p)" .br .RI "Write the stored pointer to an ostream\&. " .in -1c .PP .RI "\fB\fP" .br .in +1c .in +1c .ti -1c .RI "template bool \fBoperator==\fP (\fBconst\fP \fBshared_ptr\fP< _Tp > &__a, \fBconst\fP \fBshared_ptr\fP< _Up > &__b) noexcept" .br .ti -1c .RI "template bool \fBoperator==\fP (\fBconst\fP \fBshared_ptr\fP< _Tp > &__a, nullptr_t) noexcept" .br .RI "shared_ptr comparison with nullptr " .ti -1c .RI "template \fBvoid\fP \fBswap\fP (\fBshared_ptr\fP< _Tp > &__a, \fBshared_ptr\fP< _Tp > &__b) noexcept" .br .RI "Swap overload for shared_ptr\&. " .ti -1c .RI "template \fBshared_ptr\fP< _Tp > \fBstatic_pointer_cast\fP (\fBconst\fP \fBshared_ptr\fP< _Up > &__r) noexcept" .br .RI "Convert type of \fRshared_ptr\fP, via \fRstatic_cast\fP " .ti -1c .RI "template \fBshared_ptr\fP< _Tp > \fBconst_pointer_cast\fP (\fBconst\fP \fBshared_ptr\fP< _Up > &__r) noexcept" .br .RI "Convert type of \fRshared_ptr\fP, via \fRconst_cast\fP " .ti -1c .RI "template \fBshared_ptr\fP< _Tp > \fBdynamic_pointer_cast\fP (\fBconst\fP \fBshared_ptr\fP< _Up > &__r) noexcept" .br .RI "Convert type of \fRshared_ptr\fP, via \fRdynamic_cast\fP " .ti -1c .RI "template \fBshared_ptr\fP< _Tp > \fBreinterpret_pointer_cast\fP (\fBconst\fP \fBshared_ptr\fP< _Up > &__r) noexcept" .br .RI "Convert type of \fRshared_ptr\fP, via \fRreinterpret_cast\fP " .ti -1c .RI "template \fBshared_ptr\fP< _Tp > \fBstatic_pointer_cast\fP (\fBshared_ptr\fP< _Up > &&__r) noexcept" .br .RI "Convert type of \fRshared_ptr\fP rvalue, via \fRstatic_cast\fP " .ti -1c .RI "template \fBshared_ptr\fP< _Tp > \fBconst_pointer_cast\fP (\fBshared_ptr\fP< _Up > &&__r) noexcept" .br .RI "Convert type of \fRshared_ptr\fP rvalue, via \fRconst_cast\fP " .ti -1c .RI "template \fBshared_ptr\fP< _Tp > \fBdynamic_pointer_cast\fP (\fBshared_ptr\fP< _Up > &&__r) noexcept" .br .RI "Convert type of \fRshared_ptr\fP rvalue, via \fRdynamic_cast\fP " .ti -1c .RI "template \fBshared_ptr\fP< _Tp > \fBreinterpret_pointer_cast\fP (\fBshared_ptr\fP< _Up > &&__r) noexcept" .br .RI "Convert type of \fRshared_ptr\fP rvalue, via \fRreinterpret_cast\fP " .in -1c .in -1c .PP .RI "\fB\fP" .br .in +1c .in +1c .ti -1c .RI "template \fBshared_ptr\fP< \fB_NonArray\fP< _Tp > > \fBallocate_shared\fP (\fBconst\fP _Alloc &__a, \fB_Args\fP &&\&.\&.\&. \fB__args\fP)" .br .RI "Create an object that is owned by a shared_ptr\&. " .ti -1c .RI "template \fBshared_ptr\fP< \fB_NonArray\fP< _Tp > > \fBmake_shared\fP (\fB_Args\fP &&\&.\&.\&. \fB__args\fP)" .br .RI "Create an object that is owned by a shared_ptr\&. " .ti -1c .RI "template \fBshared_ptr\fP< \fB_UnboundedArray\fP< _Tp > > \fBallocate_shared\fP (\fBconst\fP _Alloc &__a, size_t __n)" .br .RI "Create an object that is owned by a shared_ptr\&. " .ti -1c .RI "template \fBshared_ptr\fP< \fB_BoundedArray\fP< _Tp > > \fBallocate_shared\fP (\fBconst\fP _Alloc &__a)" .br .RI "Create an object that is owned by a shared_ptr\&. " .in -1c .in -1c .SH "Detailed Description" .PP .SS "template .br class std::shared_ptr< _Tp >"A smart pointer with reference-counted copy semantics\&. .PP \fBSince\fP .RS 4 C++11 .RE .PP A \fRshared_ptr\fP object is either empty or \fIowns\fP a pointer passed to the constructor\&. Copies of a \fRshared_ptr\fP share ownership of the same pointer\&. When the last \fRshared_ptr\fP that owns the pointer is destroyed or reset, the owned pointer is freed (either by \fRdelete\fP or by invoking a custom deleter that was passed to the constructor)\&. .PP A \fRshared_ptr\fP also stores another pointer, which is usually (but not always) the same pointer as it owns\&. The stored pointer can be retrieved by calling the \fRget()\fP member function\&. .PP The equality and relational operators for \fRshared_ptr\fP only compare the stored pointer returned by \fRget()\fP, not the owned pointer\&. To test whether two \fRshared_ptr\fP objects share ownership of the same pointer see \fRstd::shared_ptr::owner_before\fP and \fRstd::owner_less\fP\&. .SH "Member Typedef Documentation" .PP .SS "template \fBusing\fP \fBstd::shared_ptr\fP< _Tp >::element_type" .PP The type pointed to by the stored pointer, remove_extent_t<_Tp> .SS "template \fBusing\fP \fBstd::shared_ptr\fP< _Tp >::weak_type" .PP The corresponding weak_ptr type for this shared_ptr\&. .PP \fBSince\fP .RS 4 C++17 .RE .PP .SH "Constructor & Destructor Documentation" .PP .SS "template \fBconstexpr\fP \fBstd::shared_ptr\fP< _Tp >::shared_ptr ()\fR [inline]\fP, \fR [constexpr]\fP, \fR [noexcept]\fP" .PP Construct an empty shared_ptr\&. .PP \fBPostcondition\fP .RS 4 use_count()==0 && get()==0 .RE .PP .SS "template \fBstd::shared_ptr\fP< _Tp >::shared_ptr (\fBconst\fP \fBshared_ptr\fP< _Tp > &)\fR [default]\fP, \fR [noexcept]\fP" .PP Copy constructor\&. .SS "template template> \fBstd::shared_ptr\fP< _Tp >::shared_ptr (\fB_Yp\fP * __p)\fR [inline]\fP, \fR [explicit]\fP" .PP Construct a shared_ptr that owns the pointer \fI__p\fP\&. .PP \fBParameters\fP .RS 4 \fI__p\fP A pointer that is convertible to element_type*\&. .RE .PP \fBPostcondition\fP .RS 4 use_count() == 1 && get() == __p .RE .PP \fBExceptions\fP .RS 4 \fIstd::bad_alloc,in\fP which case \fRdelete\fP \fI__p\fP is called\&. .RE .PP .SS "template template> \fBstd::shared_ptr\fP< _Tp >::shared_ptr (\fB_Yp\fP * __p, \fB_Deleter\fP __d)\fR [inline]\fP" .PP Construct a shared_ptr that owns the pointer \fI__p\fP and the deleter \fI__d\fP\&. .PP \fBParameters\fP .RS 4 \fI__p\fP A pointer\&. .br \fI__d\fP A deleter\&. .RE .PP \fBPostcondition\fP .RS 4 use_count() == 1 && get() == __p .RE .PP \fBExceptions\fP .RS 4 \fIstd::bad_alloc,in\fP which case \fI__d(__p)\fP is called\&. .RE .PP Requirements: _Deleter's copy constructor and destructor must not throw .PP __shared_ptr will release __p by calling __d(__p) .SS "template template \fBstd::shared_ptr\fP< _Tp >::shared_ptr (nullptr_t __p, \fB_Deleter\fP __d)\fR [inline]\fP" .PP Construct a shared_ptr that owns a null pointer and the deleter \fI__d\fP\&. .PP \fBParameters\fP .RS 4 \fI__p\fP A null pointer constant\&. .br \fI__d\fP A deleter\&. .RE .PP \fBPostcondition\fP .RS 4 use_count() == 1 && get() == __p .RE .PP \fBExceptions\fP .RS 4 \fIstd::bad_alloc,in\fP which case \fI__d(__p)\fP is called\&. .RE .PP Requirements: _Deleter's copy constructor and destructor must not throw .PP The last owner will call __d(__p) .SS "template template> \fBstd::shared_ptr\fP< _Tp >::shared_ptr (\fB_Yp\fP * __p, \fB_Deleter\fP __d, _Alloc __a)\fR [inline]\fP" .PP Construct a shared_ptr that owns the pointer \fI__p\fP and the deleter \fI__d\fP\&. .PP \fBParameters\fP .RS 4 \fI__p\fP A pointer\&. .br \fI__d\fP A deleter\&. .br \fI__a\fP An allocator\&. .RE .PP \fBPostcondition\fP .RS 4 use_count() == 1 && get() == __p .RE .PP \fBExceptions\fP .RS 4 \fIstd::bad_alloc,in\fP which case \fI__d(__p)\fP is called\&. .RE .PP Requirements: _Deleter's copy constructor and destructor must not throw _Alloc's copy constructor and destructor must not throw\&. .PP __shared_ptr will release __p by calling __d(__p) .SS "template template \fBstd::shared_ptr\fP< _Tp >::shared_ptr (nullptr_t __p, \fB_Deleter\fP __d, _Alloc __a)\fR [inline]\fP" .PP Construct a shared_ptr that owns a null pointer and the deleter \fI__d\fP\&. .PP \fBParameters\fP .RS 4 \fI__p\fP A null pointer constant\&. .br \fI__d\fP A deleter\&. .br \fI__a\fP An allocator\&. .RE .PP \fBPostcondition\fP .RS 4 use_count() == 1 && get() == __p .RE .PP \fBExceptions\fP .RS 4 \fIstd::bad_alloc,in\fP which case \fI__d(__p)\fP is called\&. .RE .PP Requirements: _Deleter's copy constructor and destructor must not throw _Alloc's copy constructor and destructor must not throw\&. .PP The last owner will call __d(__p) .SS "template template \fBstd::shared_ptr\fP< _Tp >::shared_ptr (\fBconst\fP \fBshared_ptr\fP< \fB_Yp\fP > & __r, \fBelement_type\fP * __p)\fR [inline]\fP, \fR [noexcept]\fP" .PP Constructs a \fRshared_ptr\fP instance that stores \fR__p\fP and shares ownership with \fR__r\fP\&. .PP \fBParameters\fP .RS 4 \fI__r\fP A \fRshared_ptr\fP\&. .br \fI__p\fP A pointer that will remain valid while \fR*__r\fP is valid\&. .RE .PP \fBPostcondition\fP .RS 4 \fRget() == __p && use_count() == __r\&.use_count()\fP .RE .PP This can be used to construct a \fRshared_ptr\fP to a sub-object of an object managed by an existing \fRshared_ptr\fP\&. The complete object will remain valid while any \fRshared_ptr\fP owns it, even if they don't store a pointer to the complete object\&. .PP .PP .nf shared_ptr> pii(new pair()); shared_ptr pi(pii, &pii\->first); assert(pii\&.use_count() == 2); .fi .PP .SS "template template \fBstd::shared_ptr\fP< _Tp >::shared_ptr (\fBshared_ptr\fP< \fB_Yp\fP > && __r, \fBelement_type\fP * __p)\fR [inline]\fP, \fR [noexcept]\fP" .PP Constructs a \fRshared_ptr\fP instance that stores \fR__p\fP and shares ownership with \fR__r\fP\&. .PP \fBParameters\fP .RS 4 \fI__r\fP A \fRshared_ptr\fP\&. .br \fI__p\fP A pointer that will remain valid while \fR*__r\fP is valid\&. .RE .PP \fBPostcondition\fP .RS 4 \fRget() == __p && !__r\&.use_count() && !__r\&.get()\fP .RE .PP \fBSince\fP .RS 4 C++17 .RE .PP This can be used to construct a \fRshared_ptr\fP to a sub-object of an object managed by an existing \fRshared_ptr\fP\&. The complete object will remain valid while any \fRshared_ptr\fP owns it, even if they don't store a pointer to the complete object\&. .PP .PP .nf shared_ptr> pii(new pair()); shared_ptr pi1(pii, &pii\->first); assert(pii\&.use_count() == 2); shared_ptr pi2(std::move(pii), &pii\->second); assert(pii\&.use_count() == 0); .fi .PP .SS "template template&>> \fBstd::shared_ptr\fP< _Tp >::shared_ptr (\fBconst\fP \fBshared_ptr\fP< \fB_Yp\fP > & __r)\fR [inline]\fP, \fR [noexcept]\fP" .PP If \fI__r\fP is empty, constructs an empty shared_ptr; otherwise construct a shared_ptr that shares ownership with \fI__r\fP\&. .PP \fBParameters\fP .RS 4 \fI__r\fP A shared_ptr\&. .RE .PP \fBPostcondition\fP .RS 4 get() == __r\&.get() && use_count() == __r\&.use_count() .RE .PP .SS "template \fBstd::shared_ptr\fP< _Tp >::shared_ptr (\fBshared_ptr\fP< _Tp > && __r)\fR [inline]\fP, \fR [noexcept]\fP" .PP Move-constructs a shared_ptr instance from \fI__r\fP\&. .PP \fBParameters\fP .RS 4 \fI__r\fP A shared_ptr rvalue\&. .RE .PP \fBPostcondition\fP .RS 4 *this contains the old value of \fI__r\fP, \fI__r\fP is empty\&. .RE .PP .SS "template template>> \fBstd::shared_ptr\fP< _Tp >::shared_ptr (\fBshared_ptr\fP< \fB_Yp\fP > && __r)\fR [inline]\fP, \fR [noexcept]\fP" .PP Move-constructs a shared_ptr instance from \fI__r\fP\&. .PP \fBParameters\fP .RS 4 \fI__r\fP A shared_ptr rvalue\&. .RE .PP \fBPostcondition\fP .RS 4 *this contains the old value of \fI__r\fP, \fI__r\fP is empty\&. .RE .PP .SS "template template&>> \fBstd::shared_ptr\fP< _Tp >::shared_ptr (\fBconst\fP \fBweak_ptr\fP< \fB_Yp\fP > & __r)\fR [inline]\fP, \fR [explicit]\fP" .PP Constructs a shared_ptr that shares ownership with \fI__r\fP and stores a copy of the pointer stored in \fI__r\fP\&. .PP \fBParameters\fP .RS 4 \fI__r\fP A weak_ptr\&. .RE .PP \fBPostcondition\fP .RS 4 use_count() == __r\&.use_count() .RE .PP \fBExceptions\fP .RS 4 \fIbad_weak_ptr\fP when __r\&.expired(), in which case the constructor has no effect\&. .RE .PP .SS "template \fBconstexpr\fP \fBstd::shared_ptr\fP< _Tp >::shared_ptr (nullptr_t)\fR [inline]\fP, \fR [constexpr]\fP, \fR [noexcept]\fP" .PP Construct an empty shared_ptr\&. .PP \fBPostcondition\fP .RS 4 use_count() == 0 && get() == nullptr .RE .PP .SH "Member Function Documentation" .PP .SS "template \fBelement_type\fP * std::__shared_ptr< _Tp, \fB_Lp\fP >::get () const\fR [inline]\fP, \fR [noexcept]\fP, \fR [inherited]\fP" .PP Return the stored pointer\&. .SS "template std::__shared_ptr< _Tp, \fB_Lp\fP >::operator bool () const\fR [inline]\fP, \fR [explicit]\fP, \fR [noexcept]\fP, \fR [inherited]\fP" .PP Return true if the stored pointer is not null\&. .SS "template template bool std::__shared_ptr< _Tp, \fB_Lp\fP >::owner_before (__shared_ptr< \fB_Tp1\fP, \fB_Lp\fP > \fBconst\fP & __rhs) const\fR [inline]\fP, \fR [noexcept]\fP, \fR [inherited]\fP" .PP Define an ordering based on ownership\&. This function defines a strict weak ordering between two shared_ptr or weak_ptr objects, such that one object is less than the other unless they share ownership of the same pointer, or are both empty\&. .SS "template template bool std::__shared_ptr< _Tp, \fB_Lp\fP >::owner_before (__weak_ptr< \fB_Tp1\fP, \fB_Lp\fP > \fBconst\fP & __rhs) const\fR [inline]\fP, \fR [noexcept]\fP, \fR [inherited]\fP" .PP Define an ordering based on ownership\&. This function defines a strict weak ordering between two shared_ptr or weak_ptr objects, such that one object is less than the other unless they share ownership of the same pointer, or are both empty\&. .SS "template \fBvoid\fP std::__shared_ptr< _Tp, \fB_Lp\fP >::swap (__shared_ptr< _Tp, \fB_Lp\fP > & __other)\fR [inline]\fP, \fR [noexcept]\fP, \fR [inherited]\fP" .PP Exchange both the owned pointer and the stored pointer\&. .SS "template bool std::__shared_ptr< _Tp, \fB_Lp\fP >::unique () const\fR [inline]\fP, \fR [noexcept]\fP, \fR [inherited]\fP" .PP Return true if use_count() == 1\&. .SS "template long std::__shared_ptr< _Tp, \fB_Lp\fP >::use_count () const\fR [inline]\fP, \fR [noexcept]\fP, \fR [inherited]\fP" .PP If *this owns a pointer, return the number of owners, otherwise zero\&. .SH "Author" .PP Generated automatically by Doxygen for libstdc++ from the source code\&.