Documentation Home >> Headers >> <jss/experimental_atomic.hpp> Header >> std::experimental::shared_ptr >> std::experimental::static_pointer_cast non-member function

Casts the pointer stored in the supplied std::experimental::shared_ptr instance to the specified type using static_cast and returns a std::experimental::shared_ptr instance holding the result which shares ownership with the source.

template<typename Target,typename Source)
shared_ptr<Target> static_pointer_cast(shared_ptr<Source> const& source);

Preconditions:

static_cast<Target*>(source.get()) is well-formed.

Returns:

A shared_ptr<Target> that holds the value of static_cast<Target*>(source.get()) and shares ownership with source

Postconditions:

result.get()==static_cast<Target*>(source.get()). result.use_count()==source.use_count(), !result.owner_before(source), !source.owner_before(result). If source.use_count() is non zero it is increased by 1.

Throws:

Nothing.

Header

#include <experimental/atomic>

See Also