1 .. Macros/Introspection//BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF
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)
8 BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF
9 ====================================
16 #define BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF(trait, name, default\_) \\
17 |unspecified-token-seq| \\
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|
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|
44 #include <boost/mpl/has_xxx.hpp>
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 +---------------+-------------------------------+---------------------------------------------------+
64 For any legal C++ identifiers ``trait`` and ``name``, boolean constant
65 expression ``c1``, boolean |Integral Constant| ``c2``, and arbitrary
70 BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF(trait, name, c1)
73 Appears at namespace scope.
79 Expands into an equivalent of the following class template
86 , typename fallback = boost::mpl::bool\_<c1>
94 where ``trait`` is a boolean |Metafunction| with the following
99 typedef trait<x>::type r;
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|.
113 typedef trait< x, c2 >::type r;
119 If |BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE| is defined, ``r::value
120 == c2::value``; otherwise, equivalent to
124 typedef trait<x>::type r;
132 BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF(
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 {}; };
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> ));
155 #if !defined(BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE)
156 BOOST_MPL_ASSERT(( has_xxx<test9> ));
159 BOOST_MPL_ASSERT(( has_xxx<test9, true\_> ));
165 |Macros|, |BOOST_MPL_HAS_XXX_TEMPLATE_DEF|,
166 |BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE|, |BOOST_MPL_LIMIT_METAFUNCTION_ARITY|