std::shared_ptr< _Tp >(3cxx) | std::shared_ptr< _Tp >(3cxx) |
NAME¶
std::shared_ptr< _Tp > -SYNOPSIS¶
Inherits std::__shared_ptr< _Tp, _Lp >.Public Types¶
typedef _Tp element_type
Public Member Functions¶
constexpr shared_ptr () noexcept
Friends¶
template<typename _Tp1 , typename _Alloc , typename... _Args> shared_ptr< _Tp1 > allocate_shared (const _Alloc &__a, _Args &&...__args)
Detailed Description¶
template<typename _Tp>class std::shared_ptr< _Tp >¶
A smart pointer with reference-counted copy semantics.Constructor & Destructor Documentation¶
template<typename _Tp> constexpr std::shared_ptr< _Tp >:: shared_ptr () [inline], [noexcept]¶
Construct an empty shared_ptr. Postcondition:use_count()==0 && get()==0
template<typename _Tp> template<typename _Tp1 > std::shared_ptr< _Tp >:: shared_ptr (_Tp1 *__p) [inline], [explicit]¶
Construct a shared_ptr that owns the pointer __p. Parameters:__p A pointer that is convertible to
element_type*.
Postcondition:
use_count() == 1 && get() == __p
Exceptions:
std::bad_alloc,in
which case delete __p is called.
template<typename _Tp> template<typename _Tp1 , typename _Deleter > std::shared_ptr< _Tp >::shared_ptr (_Tp1 *__p, _Deleter__d) [inline]¶
Construct a shared_ptr that owns the pointer __p and the deleter __d. Parameters:__p A pointer.
__d A deleter.
Postcondition:
use_count() == 1 && get() == __p
Exceptions:
std::bad_alloc,in
which case __d(__p) is called.
Requirements: _Deleter's copy constructor and destructor must not throw
__shared_ptr will release __p by calling __d(__p)
Definition at line 129 of file shared_ptr.h.
template<typename _Tp> template<typename _Deleter > std::shared_ptr< _Tp >::shared_ptr (nullptr_t__p, _Deleter__d) [inline]¶
Construct a shared_ptr that owns a null pointer and the deleter __d. Parameters:__p A null pointer constant.
__d A deleter.
Postcondition:
use_count() == 1 && get() == __p
Exceptions:
std::bad_alloc,in
which case __d(__p) is called.
Requirements: _Deleter's copy constructor and destructor must not throw
The last owner will call __d(__p)
Definition at line 146 of file shared_ptr.h.
template<typename _Tp> template<typename _Tp1 , typename _Deleter , typename _Alloc > std::shared_ptr< _Tp >::shared_ptr (_Tp1 *__p, _Deleter__d, _Alloc__a) [inline]¶
Construct a shared_ptr that owns the pointer __p and the deleter __d. Parameters:__p A pointer.
__d A deleter.
__a An allocator.
Postcondition:
use_count() == 1 && get() == __p
Exceptions:
std::bad_alloc,in
which case __d(__p) is called.
Requirements: _Deleter's copy constructor and destructor must not throw _Alloc's
copy constructor and destructor must not throw.
__shared_ptr will release __p by calling __d(__p)
Definition at line 165 of file shared_ptr.h.
template<typename _Tp> template<typename _Deleter , typename _Alloc > std::shared_ptr< _Tp >::shared_ptr (nullptr_t__p, _Deleter__d, _Alloc__a) [inline]¶
Construct a shared_ptr that owns a null pointer and the deleter __d. Parameters:__p A null pointer constant.
__d A deleter.
__a An allocator.
Postcondition:
use_count() == 1 && get() == __p
Exceptions:
std::bad_alloc,in
which case __d(__p) is called.
Requirements: _Deleter's copy constructor and destructor must not throw _Alloc's
copy constructor and destructor must not throw.
The last owner will call __d(__p)
Definition at line 184 of file shared_ptr.h.
template<typename _Tp> template<typename _Tp1 > std::shared_ptr< _Tp >:: shared_ptr (const shared_ptr< _Tp1 > &__r, _Tp *__p) [inline], [noexcept]¶
Constructs a shared_ptr instance that stores __p and shares ownership with __r. Parameters:<strong>r A shared_ptr.
__p A pointer that will remain valid while *r is valid.
Postcondition:
get() == __p && use_count() ==
__r.use_count()
This can be used to construct a shared_ptr to a sub-object of an
object managed by an existing shared_ptr.
shared_ptr< pair<int,int> > pii(new pair<int,int>()); shared_ptr<int> pi(pii, &pii->first); assert(pii.use_count() == 2);
template<typename _Tp> template<typename _Tp1 , typename = typename std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type> std::shared_ptr< _Tp >::shared_ptr (const shared_ptr< _Tp1 > &__r) [inline], [noexcept]¶
If __r is empty, constructs an empty shared_ptr; otherwise construct a shared_ptr that shares ownership with __r. Parameters:__r A shared_ptr.
Postcondition:
get() == __r.get() && use_count() ==
__r.use_count()
template<typename _Tp> std::shared_ptr< _Tp >:: shared_ptr (shared_ptr< _Tp > &&__r) [inline], [noexcept]¶
Move-constructs a shared_ptr instance from __r. Parameters:__r A shared_ptr rvalue.
Postcondition:
*this contains the old value of __r,
__r is empty.
template<typename _Tp> template<typename _Tp1 , typename = typename std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type> std::shared_ptr< _Tp >::shared_ptr ( shared_ptr< _Tp1 > &&__r) [inline], [noexcept]¶
Move-constructs a shared_ptr instance from __r. Parameters:__r A shared_ptr rvalue.
Postcondition:
*this contains the old value of __r,
__r is empty.
template<typename _Tp> template<typename _Tp1 > std::shared_ptr< _Tp >:: shared_ptr (const weak_ptr< _Tp1 > &__r) [inline], [explicit]¶
Constructs a shared_ptr that shares ownership with __r and stores a copy of the pointer stored in __r. Parameters:__r A weak_ptr.
Postcondition:
use_count() == __r.use_count()
Exceptions:
bad_weak_ptr when
__r.expired(), in which case the constructor has no effect.
template<typename _Tp> constexpr std::shared_ptr< _Tp >:: shared_ptr (nullptr_t__p) [inline], [noexcept]¶
Construct an empty shared_ptr. Parameters:__p A null pointer constant.
Postcondition:
use_count() == 0 && get() ==
nullptr
Friends And Related Function Documentation¶
template<typename _Tp> template<typename _Tp1 , typename _Alloc , typename... _Args> shared_ptr<_Tp1> allocate_shared (const _Alloc &__a, _Args &&...__args) [friend]¶
Create an object that is owned by a shared_ptr. Parameters:__a An allocator.
__args Arguments for the _Tp object's constructor.
Returns:
A shared_ptr that owns the newly
created object.
Exceptions:
An exception thrown from
_Alloc::allocate or from the constructor of _Tp.
A copy of __a will be used to allocate memory for the shared_ptr
and the new object.
Definition at line 596 of file shared_ptr.h.
Author¶
Generated automatically by Doxygen for libstdc++ from the source code.Sun Jan 6 2013 | libstdc++ |