Documentation Home >> Headers >> <jss/experimental_atomic.hpp> Header >> std::experimental::shared_ptr >> std::experimental::shared_ptr heterogeneous copy constructor

Construct a new std::experimental::shared_ptr object that shares ownership the supplied std::experimental::shared_ptr instance.

template<class Target>
explicit shared_ptr(shared_ptr<Target> const& p) noexcept;

Precondition:

Target* is implicitly convertible to T*.

Effects:

If p.use_count()>0, construct a new std::experimental::shared_ptr instance that shares ownership with p. Otherwise constructs a new empty std::experimental::shared_ptr instance.

Postconditions:

this->use_count()==p.use_count() and this->get()==static_cast<T*>(p.get()) for the newly-constructed std::experimental::shared_ptr object. If p.use_count()>0 before the constructor invocation then p.use_count() is increased by 1.

Throws:

Nothing.

Header

#include <experimental/atomic>

See Also