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

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

explicit weak_ptr(std::weak_ptr<T> const& p);

Effects:

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

Postconditions:

this->use_count()==p.use_count() for the newly-constructed std::experimental::weak_ptr object. p.use_count() remains unchanged.

Throws:

std::bad_alloc if memory cannot be allocated for any necessary internal structures.

Note:

If the std::weak_ptr instance was constructed from a std::experimental::shared_ptr then no allocation is necessary.

Header

#include <experimental/atomic>

See Also