1 .. Metafunctions/Type Selection//if_c |20
18 typedef |unspecified| type;
26 Returns one of its two arguments, ``T1`` or ``T2``, depending on the value of
27 integral constant ``c``. ``if_c<c,t1,t2>::type`` is a shorcut notation for
28 ``if_< bool_<c>,t1,t2 >::type``.
36 #include <boost/mpl/if.hpp>
42 +---------------+-----------------------------------+-----------------------------------------------+
43 | Parameter | Requirement | Description |
44 +===============+===================================+===============================================+
45 | ``c`` | An integral constant | A selection condition. |
46 +---------------+-----------------------------------+-----------------------------------------------+
47 | ``T1``, ``T2``| Any type | Types to select from. |
48 +---------------+-----------------------------------+-----------------------------------------------+
54 For any integral constant ``c`` and arbitrary types ``t1``, ``t2``:
59 typedef if_c<c,t1,t2>::type t;
65 Equivalent to ``typedef if_< bool_<c>,t1,t2 >::type t;``
73 typedef if_c<true,char,long>::type t1;
74 typedef if_c<false,char,long>::type t2;
76 BOOST_MPL_ASSERT(( is_same<t1, char> ));
77 BOOST_MPL_ASSERT(( is_same<t2, long> ));
82 // allocates space for an object of class T on heap or "inplace"
83 // depending on its size
84 template< typename T > struct lightweight
87 typedef typename if_c<
88 sizeof(T) <= sizeof(T*)
100 |Metafunctions|, |Integral Constant|, |if_|, |eval_if|, |bool_|
103 .. copyright:: Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams
104 Distributed under the Boost Software License, Version 1.0. (See accompanying
105 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)