]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | .. Metafunctions/Miscellaneous//always |20 |
2 | ||
3 | always | |
4 | ====== | |
5 | ||
6 | Synopsis | |
7 | -------- | |
8 | ||
9 | .. parsed-literal:: | |
10 | ||
11 | template< | |
12 | typename X | |
13 | > | |
14 | struct always | |
15 | { | |
16 | // |unspecified| | |
17 | // |...| | |
18 | }; | |
19 | ||
20 | ||
21 | Description | |
22 | ----------- | |
23 | ||
24 | ``always<X>`` specialization is a variadic |Metafunction Class| always returning the | |
25 | same type, ``X``, regardless of the number and types of passed arguments. | |
26 | ||
27 | ||
28 | Header | |
29 | ------ | |
30 | ||
31 | .. parsed-literal:: | |
32 | ||
33 | #include <boost/mpl/always.hpp> | |
34 | ||
35 | Model of | |
36 | -------- | |
37 | ||
38 | |Metafunction Class| | |
39 | ||
40 | ||
41 | Parameters | |
42 | ---------- | |
43 | ||
44 | +---------------+-------------------+-----------------------------------+ | |
45 | | Parameter | Requirement | Description | | |
46 | +===============+===================+===================================+ | |
47 | | ``X`` | Any type | A type to be returned. | | |
48 | +---------------+-------------------+-----------------------------------+ | |
49 | ||
50 | ||
51 | Expression semantics | |
52 | -------------------- | |
53 | ||
54 | For an arbitrary type ``x``: | |
55 | ||
56 | ||
57 | .. parsed-literal:: | |
58 | ||
59 | typedef always<x> f; | |
60 | ||
61 | :Return type: | |
62 | |Metafunction Class|. | |
63 | ||
64 | :Semantics: | |
65 | Equivalent to | |
66 | ||
67 | .. parsed-literal:: | |
68 | ||
69 | struct f : bind< identity<_1>, x > {}; | |
70 | ||
71 | ||
72 | Example | |
73 | ------- | |
74 | ||
75 | .. parsed-literal:: | |
76 | ||
77 | typedef always<true\_> always_true; | |
78 | ||
79 | BOOST_MPL_ASSERT(( apply< always_true,false\_> )); | |
80 | BOOST_MPL_ASSERT(( apply< always_true,false\_,false\_ > )); | |
81 | BOOST_MPL_ASSERT(( apply< always_true,false\_,false\_,false\_ > )); | |
82 | ||
83 | ||
84 | See also | |
85 | -------- | |
86 | ||
87 | |Metafunctions|, |Metafunction Class|, |identity|, |bind|, |apply| | |
88 | ||
89 | ||
90 |