Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Function dynamic_any_cast

boost::type_erasure::dynamic_any_cast

Synopsis

// In header: <boost/type_erasure/dynamic_any_cast.hpp>


template<typename R, typename Any> R (Any && arg);
template<typename R, typename Any, typename Map> 
  R (Any && arg, const  static_binding< Map > &);

Description

Downcasts or crosscasts an any.

The single argument form can only be used when R uses a single non-deduced placeholder.

Example:

// Assume that typeid_<>, copy_constructible<>, and incrementable<>
// have all been registered for int.
,  > > (<
    ,
        ,
        
    >
> ;
 = ();
++;
(() == 

Requires:

R and Any must both be specializations of any.

Requires:

PlaceholderMap must be an MPL map with a key for every non-deduced placeholder used by R. The value associated with each key should be the corresponding placeholder in Any.

Requires:

The concept of Any must include typeid_, for every placeholder which is used by R.

Throws:

bad_any_cast if the concepts used by R were not previously registered via a call to register_binding.

PrevUpHomeNext