template<
typename C
, typename T1
, typename T2
>
struct if_
{
typedef unspecified type;
};
Returns one of its two arguments, T1 or T2, depending on the value C.
Parameter |
Requirement |
Description |
C |
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,t1,t2>::type t;
Return type: | Any type. |
Semantics: | If c::value == true, t is identical to t1; otherwise t is
identical to t2. |
typedef if_<true_,char,long>::type t1;
typedef if_<false_,char,long>::type t2;
BOOST_MPL_ASSERT(( is_same<t1, char> ));
BOOST_MPL_ASSERT(( is_same<t2, long> ));
// allocates space for an object of class T on heap or "inplace"
// depending on its size
template< typename T > struct lightweight
{
// ...
typedef typename if_<
less_equal< sizeof_<T>, sizeof_<T*> >
, inplace_storage<T>
, heap_storage<T>
>::type impl_t;
impl_t impl;
};