...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Front Page / Macros / Introspection / BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF |
#define BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(trait, name, default_) \ unspecified token sequence \ /**/
Expands into a definition of a boolean unary Metafunction trait
such that for any type x trait
On the deficient compilers not capabale of performing the detection,
trait
#include <boost/mpl/has_xxx.hpp>
Parameter | Requirement | Description |
---|---|---|
trait | A legal identifier token | A name of the metafunction to be generated. |
name | A legal identifier token | A name of the member being detected. |
default_ | An boolean constant | A fallback value for the deficient compilers. |
For any legal C++ identifiers trait and name, boolean constant expression c1, boolean Integral Constant c2, and arbitrary type x:
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(trait, name, c1)
Precondition: | Appears at namespace scope. |
||||||||
---|---|---|---|---|---|---|---|---|---|
Return type: | None. |
||||||||
Semantics: | Expands into an equivalent of the following class template definition template< typename X, typename fallback = boost::mpl::bool_ where trait is a boolean Metafunction with the following semantics: typedef trait
typedef trait< x,c2 >::type r;
|
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_xxx, xxx, false) struct test1 {}; struct test2 { void xxx(); }; struct test3 { int xxx; }; struct test4 { static int xxx(); }; struct test5 { template< typename T > struct xxx {}; }; struct test6 { typedef int xxx; }; struct test7 { struct xxx; }; struct test8 { typedef void (*xxx)(); }; struct test9 { typedef void (xxx)(); }; BOOST_MPL_ASSERT_NOT(( has_xxx)); BOOST_MPL_ASSERT_NOT(( has_xxx )); BOOST_MPL_ASSERT_NOT(( has_xxx )); BOOST_MPL_ASSERT_NOT(( has_xxx )); BOOST_MPL_ASSERT_NOT(( has_xxx )); #if !defined(BOOST_MPL_CFG_NO_HAS_XXX) BOOST_MPL_ASSERT(( has_xxx )); BOOST_MPL_ASSERT(( has_xxx )); BOOST_MPL_ASSERT(( has_xxx )); BOOST_MPL_ASSERT(( has_xxx )); #endif BOOST_MPL_ASSERT(( has_xxx true_> )); BOOST_MPL_ASSERT(( has_xxx true_> )); BOOST_MPL_ASSERT(( has_xxx true_> )); BOOST_MPL_ASSERT(( has_xxx true_> ));