std::shared_ptr::shared_ptr

From Cppreference

Jump to: navigation, search
constexpr shared_ptr();
(1)
constexpr shared_ptr( std::nullptr_t );
(1)
template< class Y >
explicit shared_ptr( Y* ptr );
(1)
template< class T, class Deleter >
shared_ptr( Y* ptr, Deleter d );
(1)
template< class Deleter >
shared_ptr( std::nullptr_t, Deleter d );
(1)
template< class Y, class Deleter, class Allocator >
shared_ptr( Y* ptr, Deleter d, Allocator alloc );
(1)
template< class Deleter, class Allocator>
shared_ptr( std::nullptr_t, Deleter d, Allocator alloc );
(1)
template< class Y >
shared_ptr( const shared_ptr<Y>& r, Y *ptr );
(1)
shared_ptr( const shared_ptr& r );
(1)
template< class Y >
shared_ptr( const shared_ptr<Y>& r );
(1)
shared_ptr( shared_ptr&& r );
(1)
template< class Y >
shared_ptr( shared_ptr<Y>&& r );
(1)
template< class Y >
explicit shared_ptr(const std::weak_ptr<Y>& r);
(1)
template< class Y >
shared_ptr( std::auto_ptr<Y>&& r );
(1)
template< class Y, class Deleter >
shared_ptr( std::unique_ptr<Y,Deleter>&& r );
(1)

Constructs new shared_ptr from a variety of pointer types that refer to an object to manage. Optional deleter d can be supplied, which is later used to destroy the object when no shared_ptr objects own it. By default, delete expression is used as deleter. Proper delete expression corresponding to the supplied type is always selected, this is the reason why the constructors are implemented as templates using a separate parameter Y.

[edit] Parameters

[edit] Example

[edit] See also