Back to Arangodb

if_c

3rdParty/boost/1.78.0/libs/mpl/doc/refmanual/if-c.html

3.12.9.12.5 KB
Original Source

| Prev Next | Back Along | Up Home | Full TOC | Front Page / Metafunctions / Type Selection / if_c |

if_c

Synopsis

template<
      bool c
    , typename T1
    , typename T2
    >
struct[if\_c](./if-c.html){
    typedef_unspecified_type;
};

Description

Returns one of its two arguments, T1 or T2, depending on the value of integral constant c. if_c<c,t1,t2>::type is a shorcut notation for if_< bool_<c>,t1,t2 >::type.

#include <[boost/mpl/if.hpp](../../../../boost/mpl/if.hpp)>

Parameters

ParameterRequirementDescription
cAn integral constantA selection condition.
T1, T2Any typeTypes to select from.

Expression semantics

For any integral constant c and arbitrary types t1, t2:

typedef[if\_c](./if-c.html)<c,t1,t2>::type t;

| Return type: | Any type. | | Semantics: | Equivalent to typedef if_< bool_<c>,t1,t2 >::type t; |

Example

typedef[if\_c](./if-c.html)<true,char,long>::type t1;
typedef[if\_c](./if-c.html)<false,char,long>::type t2;[BOOST\_MPL\_ASSERT](./assert.html)(( is_same<t1, char> ));[BOOST\_MPL\_ASSERT](./assert.html)(( is_same<t2, long> ));
// allocates space for an object of class T on heap or "inplace"
// depending on its[size](./size.html)template< typename T > struct lightweight
{
    // ...
    typedef typename[if\_c](./if-c.html)<
          sizeof(T) <= sizeof(T*)
        , inplace_storage<T>
        , heap_storage<T>
        >::type impl_t;

    impl_t impl;
};

See also

Metafunctions, Integral Constant, if_, eval_if, bool_

| Prev Next | Back Along | Up Home | Full TOC |

Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |