]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/mpl/doc/src/refmanual/HAS_XXX_TEMPLATE_NAMED_DEF.rst
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / mpl / doc / src / refmanual / HAS_XXX_TEMPLATE_NAMED_DEF.rst
1 .. Macros/Introspection//BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF
2
3 .. Copyright Daniel Walker 2007.
4 .. Distributed under the Boost
5 .. Software License, Version 1.0. (See accompanying
6 .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7
8 BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF
9 ====================================
10
11 Synopsis
12 --------
13
14 .. parsed-literal::
15
16 #define BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF(trait, name, default\_) \\
17 |unspecified-token-seq| \\
18 /\*\*/
19
20
21 Description
22 -----------
23
24 Expands into the definition of a boolean |Metafunction| ``trait`` such
25 that for any type ``x`` ``trait<x>::value == true`` if and only if
26 ``x`` is a class type and has a nested template member ``x::template
27 name`` with no more than |BOOST_MPL_LIMIT_METAFUNCTION_ARITY|
28 parameters.
29
30 On deficient compilers not capable of performing the detection,
31 ``trait<x>::value`` always returns a fallback value ``default_``. A
32 boolean configuration macro, |BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE|, is
33 provided to signal or override the "deficient" status of a particular
34 compiler. |Note:| The fallback value can also be provided at the
35 point of the metafunction invocation; see the `Expression semantics`
36 section for details |-- end note|
37
38
39 Header
40 ------
41
42 .. parsed-literal::
43
44 #include <boost/mpl/has_xxx.hpp>
45
46
47 Parameters
48 ----------
49
50 +---------------+-------------------------------+---------------------------------------------------+
51 | Parameter | Requirement | Description |
52 +===============+===============================+===================================================+
53 | ``trait`` | A legal identifier token | A name of the metafunction to be generated. |
54 +---------------+-------------------------------+---------------------------------------------------+
55 | ``name`` | A legal identifier token | A name of the member being detected. |
56 +---------------+-------------------------------+---------------------------------------------------+
57 | ``default_`` | An boolean constant | A fallback value for the deficient compilers. |
58 +---------------+-------------------------------+---------------------------------------------------+
59
60
61 Expression semantics
62 --------------------
63
64 For any legal C++ identifiers ``trait`` and ``name``, boolean constant
65 expression ``c1``, boolean |Integral Constant| ``c2``, and arbitrary
66 type ``x``:
67
68 .. parsed-literal::
69
70 BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF(trait, name, c1)
71
72 :Precondition:
73 Appears at namespace scope.
74
75 :Return type:
76 None.
77
78 :Semantics:
79 Expands into an equivalent of the following class template
80 definition
81
82 .. parsed-literal::
83
84 template<
85 typename X
86 , typename fallback = boost::mpl::bool\_<c1>
87 >
88 struct trait
89 {
90 // |unspecified|
91 // ...
92 };
93
94 where ``trait`` is a boolean |Metafunction| with the following
95 semantics:
96
97 .. parsed-literal::
98
99 typedef trait<x>::type r;
100
101 :Return type:
102 |Integral Constant|.
103
104 :Semantics:
105 If |BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE| is defined, ``r::value
106 == c1``; otherwise, ``r::value == true`` if and only if ``x``
107 is a class type that has a nested template member ``x::template
108 name`` with no more than |BOOST_MPL_LIMIT_METAFUNCTION_ARITY|.
109
110
111 .. parsed-literal::
112
113 typedef trait< x, c2 >::type r;
114
115 :Return type:
116 |Integral Constant|.
117
118 :Semantics:
119 If |BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE| is defined, ``r::value
120 == c2::value``; otherwise, equivalent to
121
122 .. parsed-literal::
123
124 typedef trait<x>::type r;
125
126
127 Example
128 -------
129
130 .. parsed-literal::
131
132 BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF(
133 has_xxx, xxx, false
134 )
135
136 struct test1 {};
137 struct test2 { void xxx(); };
138 struct test3 { int xxx; };
139 struct test4 { static int xxx(); };
140 struct test5 { typedef int xxx; };
141 struct test6 { struct xxx; };
142 struct test7 { typedef void (\*xxx)(); };
143 struct test8 { typedef void (xxx)(); };
144 struct test9 { template< class T > struct xxx {}; };
145
146 BOOST_MPL_ASSERT_NOT(( has_xxx<test1> ));
147 BOOST_MPL_ASSERT_NOT(( has_xxx<test2> ));
148 BOOST_MPL_ASSERT_NOT(( has_xxx<test3> ));
149 BOOST_MPL_ASSERT_NOT(( has_xxx<test4> ));
150 BOOST_MPL_ASSERT_NOT(( has_xxx<test5> ));
151 BOOST_MPL_ASSERT_NOT(( has_xxx<test6> ));
152 BOOST_MPL_ASSERT_NOT(( has_xxx<test7> ));
153 BOOST_MPL_ASSERT_NOT(( has_xxx<test8> ));
154
155 #if !defined(BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE)
156 BOOST_MPL_ASSERT(( has_xxx<test9> ));
157 #endif
158
159 BOOST_MPL_ASSERT(( has_xxx<test9, true\_> ));
160
161
162 See also
163 --------
164
165 |Macros|, |BOOST_MPL_HAS_XXX_TEMPLATE_DEF|,
166 |BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE|, |BOOST_MPL_LIMIT_METAFUNCTION_ARITY|
167