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 polymorphic_get

boost::polymorphic_get — Retrieves a value of a specified type from a given variant.

Synopsis

// In header: <boost/variant/polymorphic_get.hpp>


template<typename U, typename T1, typename T2, ..., typename TN> 
  U * polymorphic_get(variant<T1, T2, ..., TN> * operand);
template<typename U, typename T1, typename T2, ..., typename TN> 
  const U * polymorphic_get(const variant<T1, T2, ..., TN> * operand);
template<typename U, typename T1, typename T2, ..., typename TN> 
  U & polymorphic_get(variant<T1, T2, ..., TN> & operand);
template<typename U, typename T1, typename T2, ..., typename TN> 
  const U & polymorphic_get(const variant<T1, T2, ..., TN> & operand);

Description

Evaluates to polymorphic_strict_get if BOOST_VARIANT_USE_RELAXED_GET_BY_DEFAULT is not defined. If BOOST_VARIANT_USE_RELAXED_GET_BY_DEFAULT is defined then evaluates to polymorphic_relaxed_get.

Recomendation: Use polymorphic_get in new code without defining BOOST_VARIANT_USE_RELAXED_GET_BY_DEFAULT. In that way polymorphic_get provides more compile time checks and its behavior is closer to std::get from C++ Standard Library.


PrevUpHomeNext