]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | .. Metafunctions/Type Selection//eval_if_c |40 |
2 | ||
3 | eval_if_c | |
4 | ========= | |
5 | ||
6 | Synopsis | |
7 | -------- | |
8 | ||
9 | .. parsed-literal:: | |
10 | ||
11 | template< | |
12 | bool c | |
13 | , typename F1 | |
14 | , typename F2 | |
15 | > | |
16 | struct eval_if_c | |
17 | { | |
18 | typedef |unspecified| type; | |
19 | }; | |
20 | ||
21 | ||
22 | ||
23 | Description | |
24 | ----------- | |
25 | ||
26 | Evaluates one of its two |nullary metafunction| arguments, ``F1`` or ``F2``, depending | |
27 | on the value of integral constant ``c``. ``eval_if_c<c,f1,f2>::type`` is a shorcut | |
28 | notation for ``eval_if< bool_<c>,f1,f2 >::type``. | |
29 | ||
30 | ||
31 | Header | |
32 | ------ | |
33 | ||
34 | .. parsed-literal:: | |
35 | ||
36 | #include <boost/mpl/eval_if.hpp> | |
37 | ||
38 | ||
39 | Parameters | |
40 | ---------- | |
41 | ||
42 | +---------------+-----------------------------------+-----------------------------------------------+ | |
43 | | Parameter | Requirement | Description | | |
44 | +===============+===================================+===============================================+ | |
45 | | ``c`` | An integral constant | An evaluation condition. | | |
46 | +---------------+-----------------------------------+-----------------------------------------------+ | |
47 | | ``F1``, ``F2``| Nullary |Metafunction| | Metafunctions to select for evaluation from. | | |
48 | +---------------+-----------------------------------+-----------------------------------------------+ | |
49 | ||
50 | ||
51 | Expression semantics | |
52 | -------------------- | |
53 | ||
54 | For any integral constant ``c`` and nullary |Metafunction|\ s ``f1``, ``f2``: | |
55 | ||
56 | ||
57 | .. parsed-literal:: | |
58 | ||
59 | typedef eval_if_c<c,f1,f2>::type t; | |
60 | ||
61 | :Return type: | |
62 | Any type. | |
63 | ||
64 | :Semantics: | |
65 | Equivalent to ``typedef eval_if< bool_<c>,f1,f2 >::type t;`` | |
66 | ||
67 | ||
68 | Example | |
69 | ------- | |
70 | ||
71 | .. parsed-literal:: | |
72 | ||
73 | typedef eval_if_c< true, identity<char>, identity<long> >::type t1; | |
74 | typedef eval_if_c< false, identity<char>, identity<long> >::type t2; | |
75 | ||
76 | BOOST_MPL_ASSERT(( is_same<t1,char> )); | |
77 | BOOST_MPL_ASSERT(( is_same<t2,long> )); | |
78 | ||
79 | ||
80 | See also | |
81 | -------- | |
82 | ||
83 | |Metafunctions|, |Integral Constant|, |eval_if|, |if_|, |bool_| | |
84 | ||
85 | ||
86 |