Documentation Home >> Headers >> <jss/experimental_atomic.hpp> Header >> std::experimental::shared_ptr >> std::experimental::shared_ptr raw pointer constructor with a deleter and an allocator

Construct a new std::experimental::shared_ptr object that owns the supplied pointer and deleter, using the supplied allocator to allocate and deallocate the control block.

template<class Target,class Deleter,class Allocator>
explicit shared_ptr(Target* p,Deleter d,Allocator a);

Precondition:

Target* is implicitly convertible to T*. d(p) is well-formed. Deleter is CopyConstructible. Allocator is meets the allocator requirements.

Effects:

Construct a new std::experimental::shared_ptr instance that owns p and a copy of d, using a copy of a to allocate the control block. A copy of 'a' will then be used to deallocate the control block when the last std::experimental::shared_ptr instance referencing this is destroyed or reassigned.

Postconditions:

If sp is the newly-constructed std::experimental::shared_ptr object, sp.unique() and sp.get()==static_cast<T*>(p) and get_deleter<Deleter>(sp)!=0.

Note:

This allows you to construct a std::experimental::shared_ptr for which get member function is nullptr, but use_count member function is non-zero.

Throws:

Any exception thrown by the allocator if memory for the internal data structures of std::experimental::shared_ptr could not be allocated.

Note:

If an exception is thrown, d(p) is invoked.

Header

#include <experimental/atomic>

See Also