bsl::shared_ptr::shared_ptr

Constructors

Synopses

Declared in <bslstl_sharedptr.h>

Create an empty shared pointer, i.e., a shared pointer with no representation that does not refer to any object and has no deleter.

constexpr
shared_ptr() noexcept;
» more...

Copy-construct a shared_ptr from original.

shared_ptr(shared_ptr const& original) noexcept;
» more...

Create a shared_ptr sharing ownership with a compatible other.

template<class COMPATIBLE_TYPE>
shared_ptr(shared_ptr<COMPATIBLE_TYPE> const& other) noexcept;
» more...

Move-construct a shared_ptr from a compatible other.

template<class COMPATIBLE_TYPE>
shared_ptr(shared_ptr<COMPATIBLE_TYPE>&& other) noexcept;
» more...

Create an empty shared pointer, i.e., a shared pointer with no representation that does not refer to any object and has no deleter.

constexpr
shared_ptr(bsl::nullptr_t nullPointerLiteral) noexcept;
» more...

Move-construct a shared_ptr from original.

shared_ptr(BloombergLP::bslmf::MovableRef<shared_ptr> original) noexcept;
» more...

Create a shared_ptr from a weak_ptr, or empty if expired.

template<class COMPATIBLE_TYPE>
explicit
shared_ptr(weak_ptr<COMPATIBLE_TYPE> const& ptr);
» more...

Create a shared_ptr that manages the object at ptr.

template<class CONVERTIBLE_TYPE>
explicit
shared_ptr(CONVERTIBLE_TYPE* ptr);
» more...

Create an empty shared pointer.

shared_ptr(
    nullptr_t nullPointerLiteral,
    BloombergLP::bslma::Allocator* basicAllocator);
» more...

Create a shared_ptr from the specified arguments.

explicit
shared_ptr(
    std::auto_ptr_ref<ELEMENT_TYPE> autoRef,
    BloombergLP::bslma::Allocator* basicAllocator = 0);
» more...

Create a shared_ptr from the specified arguments.

shared_ptr(
    element_type* ptr,
    BloombergLP::bslma::SharedPtrRep* rep);
» more...

Create a shared_ptr by adopting ownership from a managed pointer.

template<class CONVERTIBLE_TYPE>
shared_ptr(
    BloombergLP::bslma::ManagedPtr<CONVERTIBLE_TYPE> managedPtr,
    BloombergLP::bslma::Allocator* basicAllocator = 0);
» more...

Create a shared_ptr from the specified arguments.

template<class CONVERTIBLE_TYPE>
explicit
shared_ptr(
    std::auto_ptr<CONVERTIBLE_TYPE>& autoPtr,
    BloombergLP::bslma::Allocator* basicAllocator = 0);
» more...

Create an aliased shared_ptr sharing ownership with source.

template<class ANY_TYPE>
shared_ptr(
    shared_ptr<ANY_TYPE> const& source,
    ELEMENT_TYPE* object) noexcept;
» more...

Create a shared_ptr managing ptr using basicAllocator.

template<class CONVERTIBLE_TYPE>
shared_ptr(
    CONVERTIBLE_TYPE* ptr,
    BloombergLP::bslma::Allocator* basicAllocator);
» more...

Create a shared_ptr by adopting ownership from a unique pointer.

template<
    class COMPATIBLE_TYPE,
    class UNIQUE_DELETER>
requires is_convertible<
                      typename std::unique_ptr<COMPATIBLE_TYPE,
                                               UNIQUE_DELETER>::pointer,
                      ELEMENT_TYPE *>::value
shared_ptr(
    std::unique_ptr<COMPATIBLE_TYPE, UNIQUE_DELETER>&& adoptee,
    BloombergLP::bslma::Allocator* basicAllocator = 0);
» more...

Create a shared_ptr managing ptr with a custom deleter.

template<
    class CONVERTIBLE_TYPE,
    class DELETER>
shared_ptr(
    CONVERTIBLE_TYPE* ptr,
    DELETER* deleter);
» more...

Create a shared_ptr from the specified arguments.

shared_ptr(
    ELEMENT_TYPE* ptr,
    BloombergLP::bslma::SharedPtrRep* rep,
    BloombergLP::bslstl::SharedPtr_RepFromExistingSharedPtr tag);
» more...

Create a shared_ptr owning null with a deleter.

template<class DELETER>
shared_ptr(
    nullptr_t nullPointerLiteral,
    DELETER deleter,
    BloombergLP::bslma::Allocator* basicAllocator = 0);
» more...

Create a shared_ptr managing ptr with a deleter and allocator.

template<
    class CONVERTIBLE_TYPE,
    class DELETER>
shared_ptr(
    CONVERTIBLE_TYPE* ptr,
    DELETER deleter,
    BloombergLP::bslma::Allocator* basicAllocator = 0);
» more...

Create a shared_ptr owning null with a deleter and allocator.

template<
    class DELETER,
    class ALLOCATOR>
shared_ptr(
    nullptr_t nullPointerLiteral,
    DELETER deleter,
    ALLOCATOR basicAllocator,
    ALLOCATOR::value_type* sfinae = 0);
» more...

Create a shared_ptr managing ptr with a custom deleter.

template<
    class CONVERTIBLE_TYPE,
    class DELETER,
    class ALLOCATOR>
shared_ptr(
    CONVERTIBLE_TYPE* ptr,
    DELETER deleter,
    ALLOCATOR basicAllocator,
    ALLOCATOR::value_type* sfinae = 0);
» more...

Parameters

NameDescription
originalsource object to copy or move from
otherother pointer to compare or share ownership with
nullPointerLiteralnull-pointer literal (unused; selects this overload)
ptrpointer to the object to manage or refer to
basicAllocatorallocator used to supply memory
repshared-pointer representation object
managedPtrmanaged pointer whose ownership is transferred
sourcesource shared pointer that supplies ownership
objectobject to refer to while sharing ownership with source
adopteeunique pointer whose ownership is transferred
deleterdeleter invoked when the last shared reference is released
tagtag selecting the existing-representation constructor
sfinaeunused SFINAE discriminator