1 .. Macros/Introspection//BOOST_MPL_HAS_XXX_TEMPLATE_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_DEF
9 ==============================
16 #define BOOST_MPL_HAS_XXX_TEMPLATE_DEF(name) \\
17 |unspecified-token-seq| \\
24 Expands into the definition of a boolean |Metafunction| ``has_name``
25 such that for any type ``x`` ``has_name<x>::value == true`` if and
26 only if ``x`` is a class type and has a nested template member
27 ``x::template name`` with no more than
28 |BOOST_MPL_LIMIT_METAFUNCTION_ARITY| parameters.
30 On deficient compilers not capable of performing the detection,
31 ``has_name<x>::value`` is always ``false``. A boolean configuration
32 macro, |BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE|, is provided to signal or
33 override the "deficient" status of a particular compiler.
35 |Note:| |BOOST_MPL_HAS_XXX_TEMPLATE_DEF| is a simplified front end to
36 the |BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF| introspection macro |-- end
45 #include <boost/mpl/has_xxx.hpp>
52 +---------------+-------------------------------+---------------------------------------------------+
53 | Parameter | Requirement | Description |
54 +===============+===============================+===================================================+
55 | ``name`` | A legal identifier token | A name of the template member being detected. |
56 +---------------+-------------------------------+---------------------------------------------------+
62 For any legal C++ identifier ``name``:
66 BOOST_MPL_HAS_XXX_TEMPLATE_DEF(name)
69 Appears at namespace scope.
79 BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF(
80 BOOST_PP_CAT(has\_,name), name, false
89 BOOST_MPL_HAS_XXX_TEMPLATE_DEF(xxx)
92 struct test2 { void xxx(); };
93 struct test3 { int xxx; };
94 struct test4 { static int xxx(); };
95 struct test5 { typedef int xxx; };
96 struct test6 { struct xxx; };
97 struct test7 { typedef void (\*xxx)(); };
98 struct test8 { typedef void (xxx)(); };
99 struct test9 { template< class T > struct xxx {}; };
101 BOOST_MPL_ASSERT_NOT(( has_xxx<test1> ));
102 BOOST_MPL_ASSERT_NOT(( has_xxx<test2> ));
103 BOOST_MPL_ASSERT_NOT(( has_xxx<test3> ));
104 BOOST_MPL_ASSERT_NOT(( has_xxx<test4> ));
105 BOOST_MPL_ASSERT_NOT(( has_xxx<test5> ));
106 BOOST_MPL_ASSERT_NOT(( has_xxx<test6> ));
107 BOOST_MPL_ASSERT_NOT(( has_xxx<test7> ));
108 BOOST_MPL_ASSERT_NOT(( has_xxx<test8> ));
110 #if !defined(BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE)
111 BOOST_MPL_ASSERT(( has_xxx<test9> ));
114 BOOST_MPL_ASSERT(( has_xxx<test9, true\_> ));
120 |Macros|, |BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF|,
121 |BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE|, |BOOST_MPL_LIMIT_METAFUNCTION_ARITY|