.TH "std::unique_ptr< _Tp, _Dp >" 3cxx "Wed Jul 28 2021" "libstdc++" \" -*- nroff -*- .ad l .nh .SH NAME std::unique_ptr< _Tp, _Dp > \- 20\&.7\&.1\&.2 unique_ptr for single objects\&. .SH SYNOPSIS .br .PP .SS "Public Types" .in +1c .ti -1c .RI "using \fBdeleter_type\fP = _Dp" .br .ti -1c .RI "using \fBelement_type\fP = _Tp" .br .ti -1c .RI "using \fBpointer\fP = typename __uniq_ptr_impl< _Tp, _Dp >::pointer" .br .in -1c .SS "Public Member Functions" .in +1c .ti -1c .RI "template> constexpr \fBunique_ptr\fP () noexcept" .br .RI "Default constructor, creates a unique_ptr that owns nothing\&. " .ti -1c .RI "template \fBunique_ptr\fP (\fBauto_ptr\fP< _Up > &&__u) noexcept" .br .ti -1c .RI "\fBunique_ptr\fP (const \fBunique_ptr\fP &)=delete" .br .ti -1c .RI "template> constexpr \fBunique_ptr\fP (nullptr_t) noexcept" .br .RI "Creates a unique_ptr that owns nothing\&. " .ti -1c .RI "template> \fBunique_ptr\fP (pointer __p) noexcept" .br .ti -1c .RI "template>> \fBunique_ptr\fP (pointer __p, __enable_if_t::value, _Del && > __d) noexcept" .br .ti -1c .RI "template>> \fBunique_ptr\fP (pointer __p, const deleter_type &__d) noexcept" .br .ti -1c .RI "template::type> \fBunique_ptr\fP (pointer, __enable_if_t< \fBis_lvalue_reference\fP< _Del >::value, _DelUnref && >)=delete" .br .ti -1c .RI "\fBunique_ptr\fP (\fBunique_ptr\fP &&)=default" .br .RI "Move constructor\&. " .ti -1c .RI "template, typename conditional::value, is_same<_Ep, _Dp>, is_convertible<_Ep, _Dp>>::type>> \fBunique_ptr\fP (\fBunique_ptr\fP< _Up, _Ep > &&__u) noexcept" .br .RI "Converting constructor from another type\&. " .ti -1c .RI "\fB~unique_ptr\fP () noexcept" .br .RI "Destructor, invokes the deleter if the stored pointer is not null\&. " .ti -1c .RI "pointer \fBget\fP () const noexcept" .br .RI "Return the stored pointer\&. " .ti -1c .RI "const deleter_type & \fBget_deleter\fP () const noexcept" .br .RI "Return a reference to the stored deleter\&. " .ti -1c .RI "deleter_type & \fBget_deleter\fP () noexcept" .br .RI "Return a reference to the stored deleter\&. " .ti -1c .RI "\fBoperator bool\fP () const noexcept" .br .RI "Return \fCtrue\fP if the stored pointer is not null\&. " .ti -1c .RI "\fBadd_lvalue_reference\fP< element_type >::type \fBoperator*\fP () const" .br .RI "Dereference the stored pointer\&. " .ti -1c .RI "pointer \fBoperator\->\fP () const noexcept" .br .RI "Return the stored pointer\&. " .ti -1c .RI "\fBunique_ptr\fP & \fBoperator=\fP (const \fBunique_ptr\fP &)=delete" .br .ti -1c .RI "\fBunique_ptr\fP & \fBoperator=\fP (nullptr_t) noexcept" .br .RI "Reset the unique_ptr to empty, invoking the deleter if necessary\&. " .ti -1c .RI "\fBunique_ptr\fP & \fBoperator=\fP (\fBunique_ptr\fP &&)=default" .br .RI "Move assignment operator\&. " .ti -1c .RI "template \fBenable_if\fP< __and_< __safe_conversion_up< _Up, _Ep >, \fBis_assignable\fP< deleter_type &, _Ep && > >::value, \fBunique_ptr\fP & >::type \fBoperator=\fP (\fBunique_ptr\fP< _Up, _Ep > &&__u) noexcept" .br .RI "Assignment from another type\&. " .ti -1c .RI "pointer \fBrelease\fP () noexcept" .br .RI "Release ownership of any stored pointer\&. " .ti -1c .RI "void \fBreset\fP (pointer __p=pointer()) noexcept" .br .RI "Replace the stored pointer\&. " .ti -1c .RI "void \fBswap\fP (\fBunique_ptr\fP &__u) noexcept" .br .RI "Exchange the pointer and deleter with another object\&. " .in -1c .SS "Related Functions" (Note that these are not member functions\&.) .PP .RI "\fB\fP" .br .in +1c .in +1c .ti -1c .RI "template \fBenable_if\fP< __is_swappable< _Dp >::value >::type \fBswap\fP (\fBunique_ptr\fP< _Tp, _Dp > &__x, \fBunique_ptr\fP< _Tp, _Dp > &__y) noexcept" .br .ti -1c .RI "template bool \fBoperator==\fP (const \fBunique_ptr\fP< _Tp, _Dp > &__x, const \fBunique_ptr\fP< _Up, _Ep > &__y)" .br .RI "Equality operator for unique_ptr objects, compares the owned pointers\&. " .ti -1c .RI "template bool \fBoperator==\fP (const \fBunique_ptr\fP< _Tp, _Dp > &__x, nullptr_t) noexcept" .br .RI "unique_ptr comparison with nullptr " .ti -1c .RI "template bool \fBoperator==\fP (nullptr_t, const \fBunique_ptr\fP< _Tp, _Dp > &__x) noexcept" .br .RI "unique_ptr comparison with nullptr " .ti -1c .RI "template bool \fBoperator!=\fP (const \fBunique_ptr\fP< _Tp, _Dp > &__x, const \fBunique_ptr\fP< _Up, _Ep > &__y)" .br .RI "Inequality operator for unique_ptr objects, compares the owned pointers\&. " .ti -1c .RI "template bool \fBoperator!=\fP (const \fBunique_ptr\fP< _Tp, _Dp > &__x, nullptr_t) noexcept" .br .RI "unique_ptr comparison with nullptr " .ti -1c .RI "template bool \fBoperator!=\fP (nullptr_t, const \fBunique_ptr\fP< _Tp, _Dp > &__x) noexcept" .br .RI "unique_ptr comparison with nullptr " .ti -1c .RI "template bool \fBoperator<\fP (const \fBunique_ptr\fP< _Tp, _Dp > &__x, const \fBunique_ptr\fP< _Up, _Ep > &__y)" .br .RI "Relational operator for unique_ptr objects, compares the owned pointers\&. " .ti -1c .RI "template bool \fBoperator<\fP (const \fBunique_ptr\fP< _Tp, _Dp > &__x, nullptr_t)" .br .RI "unique_ptr comparison with nullptr " .ti -1c .RI "template bool \fBoperator<\fP (nullptr_t, const \fBunique_ptr\fP< _Tp, _Dp > &__x)" .br .RI "unique_ptr comparison with nullptr " .ti -1c .RI "template bool \fBoperator<=\fP (const \fBunique_ptr\fP< _Tp, _Dp > &__x, const \fBunique_ptr\fP< _Up, _Ep > &__y)" .br .RI "Relational operator for unique_ptr objects, compares the owned pointers\&. " .ti -1c .RI "template bool \fBoperator<=\fP (const \fBunique_ptr\fP< _Tp, _Dp > &__x, nullptr_t)" .br .RI "unique_ptr comparison with nullptr " .ti -1c .RI "template bool \fBoperator<=\fP (nullptr_t, const \fBunique_ptr\fP< _Tp, _Dp > &__x)" .br .RI "unique_ptr comparison with nullptr " .ti -1c .RI "template bool \fBoperator>\fP (const \fBunique_ptr\fP< _Tp, _Dp > &__x, const \fBunique_ptr\fP< _Up, _Ep > &__y)" .br .RI "Relational operator for unique_ptr objects, compares the owned pointers\&. " .ti -1c .RI "template bool \fBoperator>\fP (const \fBunique_ptr\fP< _Tp, _Dp > &__x, nullptr_t)" .br .RI "unique_ptr comparison with nullptr " .ti -1c .RI "template bool \fBoperator>\fP (nullptr_t, const \fBunique_ptr\fP< _Tp, _Dp > &__x)" .br .RI "unique_ptr comparison with nullptr " .ti -1c .RI "template bool \fBoperator>=\fP (const \fBunique_ptr\fP< _Tp, _Dp > &__x, const \fBunique_ptr\fP< _Up, _Ep > &__y)" .br .RI "Relational operator for unique_ptr objects, compares the owned pointers\&. " .ti -1c .RI "template bool \fBoperator>=\fP (const \fBunique_ptr\fP< _Tp, _Dp > &__x, nullptr_t)" .br .RI "unique_ptr comparison with nullptr " .ti -1c .RI "template bool \fBoperator>=\fP (nullptr_t, const \fBunique_ptr\fP< _Tp, _Dp > &__x)" .br .RI "unique_ptr comparison with nullptr " .in -1c .in -1c .PP .RI "\fB\fP" .br .in +1c .in +1c .ti -1c .RI "template _MakeUniq< _Tp >::__single_object \fBmake_unique\fP (_Args &&\&.\&.\&. __args)" .br .RI "std::make_unique for single objects " .ti -1c .RI "template _MakeUniq< _Tp >::__array \fBmake_unique\fP (size_t __num)" .br .RI "std::make_unique for arrays of unknown bound " .ti -1c .RI "template _MakeUniq< _Tp >::__invalid_type \fBmake_unique\fP (_Args &&\&.\&.\&.)=delete" .br .RI "Disable std::make_unique for arrays of known bound\&. " .in -1c .in -1c .SH "Detailed Description" .PP .SS "template> .br class std::unique_ptr< _Tp, _Dp >" 20\&.7\&.1\&.2 unique_ptr for single objects\&. .PP Definition at line 242 of file unique_ptr\&.h\&. .SH "Constructor & Destructor Documentation" .PP .SS "template> template> constexpr \fBstd::unique_ptr\fP< _Tp, _Dp >::\fBunique_ptr\fP ()\fC [inline]\fP, \fC [constexpr]\fP, \fC [noexcept]\fP" .PP Default constructor, creates a unique_ptr that owns nothing\&. .PP Definition at line 269 of file unique_ptr\&.h\&. .SS "template> template> \fBstd::unique_ptr\fP< _Tp, _Dp >::\fBunique_ptr\fP (pointer __p)\fC [inline]\fP, \fC [explicit]\fP, \fC [noexcept]\fP" Takes ownership of a pointer\&. .PP \fBParameters\fP .RS 4 \fI__p\fP A pointer to an object of \fCelement_type\fP .RE .PP The deleter will be value-initialized\&. .PP Definition at line 281 of file unique_ptr\&.h\&. .SS "template> template>> \fBstd::unique_ptr\fP< _Tp, _Dp >::\fBunique_ptr\fP (pointer __p, const deleter_type & __d)\fC [inline]\fP, \fC [noexcept]\fP" Takes ownership of a pointer\&. .PP \fBParameters\fP .RS 4 \fI__p\fP A pointer to an object of \fCelement_type\fP .br \fI__d\fP A reference to a deleter\&. .RE .PP The deleter will be initialized with \fC__d\fP .PP Definition at line 294 of file unique_ptr\&.h\&. .SS "template> template>> \fBstd::unique_ptr\fP< _Tp, _Dp >::\fBunique_ptr\fP (pointer __p, __enable_if_t::value, _Del && > __d)\fC [inline]\fP, \fC [noexcept]\fP" Takes ownership of a pointer\&. .PP \fBParameters\fP .RS 4 \fI__p\fP A pointer to an object of \fCelement_type\fP .br \fI__d\fP An rvalue reference to a (non-reference) deleter\&. .RE .PP The deleter will be initialized with \fCstd::move(__d)\fP .PP Definition at line 306 of file unique_ptr\&.h\&. .SS "template> template> constexpr \fBstd::unique_ptr\fP< _Tp, _Dp >::\fBunique_ptr\fP (nullptr_t)\fC [inline]\fP, \fC [constexpr]\fP, \fC [noexcept]\fP" .PP Creates a unique_ptr that owns nothing\&. .PP Definition at line 320 of file unique_ptr\&.h\&. .SS "template> \fBstd::unique_ptr\fP< _Tp, _Dp >::\fBunique_ptr\fP (\fBunique_ptr\fP< _Tp, _Dp > &&)\fC [default]\fP" .PP Move constructor\&. .SS "template> template, typename conditional::value, is_same<_Ep, _Dp>, is_convertible<_Ep, _Dp>>::type>> \fBstd::unique_ptr\fP< _Tp, _Dp >::\fBunique_ptr\fP (\fBunique_ptr\fP< _Up, _Ep > && __u)\fC [inline]\fP, \fC [noexcept]\fP" .PP Converting constructor from another type\&. Requires that the pointer owned by \fC__u\fP is convertible to the type of pointer owned by this object, \fC__u\fP does not own an array, and \fC__u\fP has a compatible deleter type\&. .PP Definition at line 340 of file unique_ptr\&.h\&. .SS "template> \fBstd::unique_ptr\fP< _Tp, _Dp >::~\fBunique_ptr\fP ()\fC [inline]\fP, \fC [noexcept]\fP" .PP Destructor, invokes the deleter if the stored pointer is not null\&. .PP Definition at line 355 of file unique_ptr\&.h\&. .SH "Member Function Documentation" .PP .SS "template> pointer \fBstd::unique_ptr\fP< _Tp, _Dp >::get (void) const\fC [inline]\fP, \fC [noexcept]\fP" .PP Return the stored pointer\&. .PP Definition at line 421 of file unique_ptr\&.h\&. .PP Referenced by std::unique_ptr< _Tp, _Dp >::operator bool(), std::unique_ptr< _Tp[], _Dp >::operator bool(), std::unique_ptr< _Tp, _Dp >::operator!=(), std::unique_ptr< _Tp, _Dp >::operator==(), and std::unique_ptr< _Tp, _Dp >::operator>()\&. .SS "template> const deleter_type& \fBstd::unique_ptr\fP< _Tp, _Dp >::get_deleter () const\fC [inline]\fP, \fC [noexcept]\fP" .PP Return a reference to the stored deleter\&. .PP Definition at line 431 of file unique_ptr\&.h\&. .SS "template> deleter_type& \fBstd::unique_ptr\fP< _Tp, _Dp >::get_deleter ()\fC [inline]\fP, \fC [noexcept]\fP" .PP Return a reference to the stored deleter\&. .PP Definition at line 426 of file unique_ptr\&.h\&. .PP Referenced by std::unique_ptr< _Tp[], _Dp >::~unique_ptr(), std::unique_ptr< _Tp, _Dp >::operator=(), and std::unique_ptr< _Tp[], _Dp >::operator=()\&. .SS "template> \fBstd::unique_ptr\fP< _Tp, _Dp >::operator bool () const\fC [inline]\fP, \fC [explicit]\fP, \fC [noexcept]\fP" .PP Return \fCtrue\fP if the stored pointer is not null\&. .PP Definition at line 435 of file unique_ptr\&.h\&. .PP References std::unique_ptr< _Tp, _Dp >::get()\&. .SS "template> \fBadd_lvalue_reference\fP::type \fBstd::unique_ptr\fP< _Tp, _Dp >::operator* () const\fC [inline]\fP" .PP Dereference the stored pointer\&. .PP Definition at line 405 of file unique_ptr\&.h\&. .SS "template> pointer \fBstd::unique_ptr\fP< _Tp, _Dp >::operator\-> () const\fC [inline]\fP, \fC [noexcept]\fP" .PP Return the stored pointer\&. .PP Definition at line 413 of file unique_ptr\&.h\&. .SS "template> \fBunique_ptr\fP& \fBstd::unique_ptr\fP< _Tp, _Dp >::operator= (nullptr_t)\fC [inline]\fP, \fC [noexcept]\fP" .PP Reset the unique_ptr to empty, invoking the deleter if necessary\&. .PP Definition at line 395 of file unique_ptr\&.h\&. .PP References std::unique_ptr< _Tp, _Dp >::reset()\&. .SS "template> \fBunique_ptr\fP& \fBstd::unique_ptr\fP< _Tp, _Dp >::operator= (\fBunique_ptr\fP< _Tp, _Dp > &&)\fC [default]\fP" .PP Move assignment operator\&. Invokes the deleter if this object owns a pointer\&. .SS "template> template \fBenable_if\fP< __and_< __safe_conversion_up<_Up, _Ep>, \fBis_assignable\fP >::value, \fBunique_ptr\fP&>::type \fBstd::unique_ptr\fP< _Tp, _Dp >::operator= (\fBunique_ptr\fP< _Up, _Ep > && __u)\fC [inline]\fP, \fC [noexcept]\fP" .PP Assignment from another type\&. .PP \fBParameters\fP .RS 4 \fI__u\fP The object to transfer ownership from, which owns a convertible pointer to a non-array object\&. .RE .PP Invokes the deleter if this object owns a pointer\&. .PP Definition at line 386 of file unique_ptr\&.h\&. .PP References std::unique_ptr< _Tp, _Dp >::get_deleter(), and std::unique_ptr< _Tp, _Dp >::reset()\&. .SS "template> pointer \fBstd::unique_ptr\fP< _Tp, _Dp >::release ()\fC [inline]\fP, \fC [noexcept]\fP" .PP Release ownership of any stored pointer\&. .PP Definition at line 442 of file unique_ptr\&.h\&. .SS "template> void \fBstd::unique_ptr\fP< _Tp, _Dp >::reset (pointer __p = \fCpointer()\fP)\fC [inline]\fP, \fC [noexcept]\fP" .PP Replace the stored pointer\&. .PP \fBParameters\fP .RS 4 \fI__p\fP The new pointer to store\&. .RE .PP The deleter will be invoked if a pointer is already owned\&. .PP Definition at line 452 of file unique_ptr\&.h\&. .PP Referenced by std::unique_ptr< _Tp, _Dp >::operator=(), and std::unique_ptr< _Tp[], _Dp >::operator=()\&. .SS "template> void \fBstd::unique_ptr\fP< _Tp, _Dp >::swap (\fBunique_ptr\fP< _Tp, _Dp > & __u)\fC [inline]\fP, \fC [noexcept]\fP" .PP Exchange the pointer and deleter with another object\&. .PP Definition at line 461 of file unique_ptr\&.h\&. .SH "Author" .PP Generated automatically by Doxygen for libstdc++ from the source code\&.