Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Function template runtime_pointer_cast

boost::typeindex::runtime_pointer_cast — Creates a new instance of std::shared_ptr whose stored pointer is obtained from u's stored pointer using a runtime_cast.

Synopsis

// In header: <boost/type_index/runtime_cast/boost_shared_ptr_cast.hpp>


template<typename T, typename U> 
  boost::shared_ptr< T > 
  runtime_pointer_cast(boost::shared_ptr< U > const & u);

Description

The new shared_ptr will share ownership with u, except that it is empty if the runtime_cast performed by runtime_pointer_cast returns a null pointer.

Template Parameters:

T

The desired target type to return a pointer of.

U

A complete class type of the source instance pointed to from u.

Returns:

If there exists a valid conversion from U* to T*, returns a boost::shared_ptr<T> that points to an address suitably offset from u. If no such conversion exists, returns boost::shared_ptr<T>();


PrevUpHomeNext