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

PrevUpHomeNext

Function get

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

Synopsis

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


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

Description

Evaluates to 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 relaxed_get.

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


PrevUpHomeNext