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 for the latest Boost documentation.
PrevUpHomeNext

Function template runtime_cast

boost::typeindex::runtime_cast — Safely converts references to classes up, down, and sideways along the inheritance hierarchy.

Synopsis

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


template<typename T, typename U> 
  boost::add_reference< T >::type runtime_cast(U & u);

Description

Template Parameters:

T

The desired target type. Like dynamic_cast, must be a pointer to complete class type.

U

A complete class type of the source instance, u.

Returns:

If there exists a valid conversion from U& to T, returns a T that references an address suitably offset from u. If no such conversion exists, throws boost::typeindex::bad_runtime_cast.


PrevUpHomeNext