std::experimental::static_pointer_cast, std::experimental::dynamic_pointer_cast, std::experimental::const_pointer_cast, std::experimental::

From cppreference.com
Experimental
Technical Specification
Filesystem library (filesystem TS)
Library fundamentals (library fundamentals TS)
Library fundamentals 2 (library fundamentals TS v2)
Library fundamentals 3 (library fundamentals TS v3)
Extensions for parallelism (parallelism TS)
Extensions for parallelism 2 (parallelism TS v2)
Extensions for concurrency (concurrency TS)
Extensions for concurrency 2 (concurrency TS v2)
Concepts (concepts TS)
Ranges (ranges TS)
Reflection (reflection TS)
Mathematical special functions (special functions TR)
Experimental Non-TS
Pattern Matching
Linear Algebra
std::execution
Contracts
2D Graphics
std::experimental::shared_ptr
Member functions
Non-member functions
experimental::static_pointer_castexperimental::dynamic_pointer_castexperimental::const_pointer_castexperimental::reinterpret_pointer_cast
Members and non-members identical to those of std::shared_ptr
template < class T, class U >

std::experimental::shared_ptr <T>

    static_pointer_cast( const std::experimental::shared_ptr <U> & r ) noexcept ;
(1) (library fundamentals TS)
template < class T, class U >

std::experimental::shared_ptr <T>

    dynamic_pointer_cast( const std::experimental::shared_ptr <U> & r ) noexcept ;
(2) (library fundamentals TS)
template < class T, class U >

std::experimental::shared_ptr <T>

    const_pointer_cast( const std::experimental::shared_ptr <U> & r ) noexcept ;
(3) (library fundamentals TS)
template < class T, class U >

std::experimental::shared_ptr <T>

    reinterpret_pointer_cast( const std::experimental::shared_ptr <U> & r ) noexcept ;
(4) (library fundamentals TS)

Creates a new instance of std::experimental::shared_ptr whose stored pointer is obtained from r's stored pointer using a cast expression. If r is empty, so is the new shared_ptr

Otherwise, the new shared_ptr will share ownership with r, except that it is empty if the dynamic_cast performed by dynamic_pointer_cast

Let Y be typename std::experimental::shared_ptr <T> :: element_type , then the resulting std::experimental::shared_ptr

1) static_cast <Y* > (r.get ( ) )
2) dynamic_cast <Y* > (r.get ( ) ) (if the result of the dynamic_cast is a null pointer value, the returned shared_ptr
3) const_cast <Y* > (r.get ( ) )
4) reinterpret_cast <Y* > (r.get ( ) )

The behavior of these functions is undefined unless the corresponding cast from U* to T* is well formed:

1) The behavior is undefined unless static_cast <T* > ( (U* )nullptr)
2) The behavior is undefined unless dynamic_cast <T* > ( (U* )nullptr)
3) The behavior is undefined unless const_cast <T* > ( (U* )nullptr)
4) The behavior is undefined unless reinterpret_cast <T* > ( (U* )nullptr)

Parameters

r - the pointer to convert

Example

See also

constructs new shared_ptr
(public member function)
applies static_cast, dynamic_cast, const_cast, or reinterpret_cast to the stored pointer
(function template)