]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | .. Metafunctions/Logical Operations//and_ |10 |
2 | ||
3 | and\_ | |
4 | ===== | |
5 | ||
6 | Synopsis | |
7 | -------- | |
8 | ||
9 | .. parsed-literal:: | |
10 | ||
11 | template< | |
12 | typename F1 | |
13 | , typename F2 | |
14 | |...| | |
15 | , typename F\ *n* = |unspecified| | |
16 | > | |
17 | struct and\_ | |
18 | { | |
19 | typedef |unspecified| type; | |
20 | }; | |
21 | ||
22 | ||
23 | ||
24 | Description | |
25 | ----------- | |
26 | ||
27 | Returns the result of short-circuit *logical and* (``&&``) operation on its arguments. | |
28 | ||
29 | ||
30 | Header | |
31 | ------ | |
32 | ||
33 | .. parsed-literal:: | |
34 | ||
35 | #include <boost/mpl/and.hpp> | |
36 | #include <boost/mpl/logical.hpp> | |
37 | ||
38 | ||
39 | Parameters | |
40 | ---------- | |
41 | ||
42 | +---------------+---------------------------+-----------------------------------------------+ | |
43 | | Parameter | Requirement | Description | | |
44 | +===============+===========================+===============================================+ | |
45 | | |F1...Fn| | Nullary |Metafunction| | Operation's arguments. | | |
46 | +---------------+---------------------------+-----------------------------------------------+ | |
47 | ||
48 | ||
49 | Expression semantics | |
50 | -------------------- | |
51 | ||
52 | For arbitrary nullary |Metafunction|\ s |f1...fn|: | |
53 | ||
54 | .. parsed-literal:: | |
55 | ||
56 | typedef and_<f1,f2,\ |...|\ ,f\ *n*\>::type r; | |
57 | ||
58 | :Return type: | |
59 | |Integral Constant|. | |
60 | ||
61 | :Semantics: | |
62 | ``r`` is ``false_`` if either of ``f1::type::value``, ``f2::type::value``,... | |
63 | ``fn::type::value`` expressions evaluates to ``false``, and ``true_`` otherwise; | |
64 | guarantees left-to-right evaluation; the operands subsequent to the first | |
65 | ``f``\ *i* metafunction that evaluates to ``false`` are not evaluated. | |
66 | ||
67 | ||
68 | .. .......................................................................... | |
69 | ||
70 | .. parsed-literal:: | |
71 | ||
72 | typedef and_<f1,f2,\ |...|\ ,f\ *n*\> r; | |
73 | ||
74 | :Return type: | |
75 | |Integral Constant|. | |
76 | ||
77 | :Semantics: | |
78 | Equivalent to | |
79 | ||
80 | .. parsed-literal:: | |
81 | ||
82 | struct r : and_<f1,f2,\ |...|\ ,f\ *n*\>::type {}; | |
83 | ||
84 | ||
85 | Example | |
86 | ------- | |
87 | ||
88 | .. parsed-literal:: | |
89 | ||
90 | struct unknown; | |
91 | ||
92 | BOOST_MPL_ASSERT(( and_< true\_,true\_ > )); | |
93 | BOOST_MPL_ASSERT_NOT(( and_< false\_,true\_ > )); | |
94 | BOOST_MPL_ASSERT_NOT(( and_< true\_,false\_ > )); | |
95 | BOOST_MPL_ASSERT_NOT(( and_< false\_,false\_ > )); | |
96 | BOOST_MPL_ASSERT_NOT(( and_< false\_,unknown > )); // OK | |
97 | BOOST_MPL_ASSERT_NOT(( and_< false\_,unknown,unknown > )); // OK too | |
98 | ||
99 | ||
100 | See also | |
101 | -------- | |
102 | ||
103 | |Metafunctions|, |Logical Operations|, |or_|, |not_| | |
104 | ||
105 | ||
106 |