...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Front Page / Metafunctions / Type Selection / if_c |
Returns one of its two arguments, T1 or T2, depending on the value of
integral constant c. if_c
#include <boost/mpl/if.hpp>
Parameter | Requirement | Description |
---|---|---|
c | An integral constant | A selection condition. |
T1, T2 | Any type | Types to select from. |
For any integral constant c and arbitrary types t1, t2:
typedef if_c::type t;
Return type: | Any type. |
---|---|
Semantics: | Equivalent to typedef if_< bool_ |
typedef if_c::type t1; typedef if_c ::type t2; BOOST_MPL_ASSERT(( is_same )); BOOST_MPL_ASSERT(( is_same ));
// allocates space for an object of class T on heap or "inplace" // depending on its size template< typename T > struct lightweight { // ... typedef typename if_c< sizeof(T) <= sizeof(T*) , inplace_storage, heap_storage >::type impl_t; impl_t impl; };