Back to Arangodb

BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF

3rdParty/boost/1.78.0/libs/mpl/doc/refmanual/has-xxx-trait-named-def.html

3.12.9.14.9 KB
Original Source

| Prev Next | Back Along | Up Home | Full TOC | Front Page / Macros / Introspection / BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF |

BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF

Synopsis

#define[BOOST\_MPL\_HAS\_XXX\_TRAIT\_NAMED\_DEF](./has-xxx-trait-named-def.html)(trait, name, default_) \_unspecified token sequence_\
/**/

Description

Expands into a definition of a boolean unary Metafunction trait such that for any type x trait<x>::value == true if and only if x is a class type and has a nested type memeber x::name.

On the deficient compilers not capabale of performing the detection, trait<x>::value always returns a fallback value default_. A boolean configuraion macro, BOOST_MPL_CFG_NO_HAS_XXX, is provided to signal or override the "deficient" status of a particular compiler. [Note: The fallback value can also be provided at the point of the metafunction invocation; see the Expression semantics section for details — end note]

#include <[boost/mpl/has\_xxx.hpp](../../../../boost/mpl/has_xxx.hpp)>

Parameters

ParameterRequirementDescription
traitA legal identifier tokenA name of the metafunction to be generated.
nameA legal identifier tokenA name of the member being detected.
default_An boolean constantA fallback value for the deficient compilers.

Expression semantics

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](./has-xxx-trait-named-def.html)(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\_](./bool.html)<c1> >
struct trait
{
    //_unspecified_// ...
};

where trait is a boolean Metafunction with the following semantics:

typedef trait<x>::type r;

| Return type: | Integral Constant. | | Semantics: | If BOOST_MPL_CFG_NO_HAS_XXX is defined, r::value == c1; otherwise, r::value == true if and only if x is a class type that has a nested type memeber x::name. |

typedef trait< x,c2 >::type r;

| Return type: |

Integral Constant.

| | Semantics: |

If BOOST_MPL_CFG_NO_HAS_XXX is defined, r::value == c2::value; otherwise, equivalent to

typedef trait<x>::type r;

|

|

Example

[BOOST\_MPL\_HAS\_XXX\_TRAIT\_NAMED\_DEF](./has-xxx-trait-named-def.html)(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](./assert-not.html)(( has_xxx<test1> ));[BOOST\_MPL\_ASSERT\_NOT](./assert-not.html)(( has_xxx<test2> ));[BOOST\_MPL\_ASSERT\_NOT](./assert-not.html)(( has_xxx<test3> ));[BOOST\_MPL\_ASSERT\_NOT](./assert-not.html)(( has_xxx<test4> ));[BOOST\_MPL\_ASSERT\_NOT](./assert-not.html)(( has_xxx<test5> ));

#if !defined([BOOST\_MPL\_CFG\_NO\_HAS\_XXX](./cfg-no-has-xxx.html))[BOOST\_MPL\_ASSERT](./assert.html)(( has_xxx<test6> ));[BOOST\_MPL\_ASSERT](./assert.html)(( has_xxx<test7> ));[BOOST\_MPL\_ASSERT](./assert.html)(( has_xxx<test8> ));[BOOST\_MPL\_ASSERT](./assert.html)(( has_xxx<test9> ));
#endif[BOOST\_MPL\_ASSERT](./assert.html)(( has_xxx<test6,[true\_](./bool.html)> ));[BOOST\_MPL\_ASSERT](./assert.html)(( has_xxx<test7,[true\_](./bool.html)> ));[BOOST\_MPL\_ASSERT](./assert.html)(( has_xxx<test8,[true\_](./bool.html)> ));[BOOST\_MPL\_ASSERT](./assert.html)(( has_xxx<test9,[true\_](./bool.html)> ));

See also

Macros, BOOST_MPL_HAS_XXX_TRAIT_DEF, BOOST_MPL_CFG_NO_HAS_XXX

| Prev Next | Back Along | Up Home | Full TOC |

Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |