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

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

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

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:

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

Note:

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

Note:

The std::tr1::shared_ptr use count will not increase if any further copies of the std::experimental::shared_ptr instance are made.

Header

#include <experimental/atomic>

See Also