Documentation Home >> Headers >> <jss/experimental_atomic.hpp> Header >> std::experimental::shared_ptr >> std::experimental::shared_ptr constructor from a std::experimental::weak_ptr

Constructs a new std::experimental::shared_ptr object that owns the pointer held in a std::experimental::weak_ptr instance and shares ownership with the std::experimental::shared_ptr object that the std::experimental::weak_ptr was constructed from.

template<typename Target>
explicit shared_ptr(weak_ptr<Target> const& p);

Preconditions:

Target* is implicitly convertible to T*.

Effects:

If p.expired() is true, throws std::experimental::bad_weak_ptr. Otherwise constructs a new std::experimental::shared_ptr instance with the value held by the std::experimental::weak_ptr that shares ownership with the std::experimental::shared_ptr that the std::experimental::weak_ptr was constructed from.

Postconditions:

this->use_count()==p.use_count(). !this->owner_before(p). !p.owner_before(*this). this->get() has the value static_cast<T*>(q) where q is the pointer stored in p.

Throws:

std::experimental::bad_weak_ptr if p.expired().

Header

#include <experimental/atomic>

See Also