mirror of
https://github.com/boostorg/mpl.git
synced 2026-08-07 14:14:24 +02:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 41f8dec265 | |||
| 41ab25a8a1 | |||
| cbd633b4d0 | |||
| fb038c188d | |||
| 315ad7d60d | |||
| ea638a4478 | |||
| e66d77051e | |||
| 9e138e28ca | |||
| 75e47b8597 | |||
| c5621d99cd | |||
| 31a2c78a5a |
Executable → Regular
@@ -0,0 +1,32 @@
|
||||
.. Macros/Configuration//BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE |20
|
||||
|
||||
.. Copyright Daniel Walker 2007.
|
||||
.. 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)
|
||||
|
||||
BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE
|
||||
=================================
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
// #define BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE
|
||||
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
``BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE`` is a boolean configuration
|
||||
macro signaling availability of the |BOOST_MPL_HAS_XXX_TEMPLATE_DEF| /
|
||||
|BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF| introspection macros'
|
||||
functionality on a particular compiler.
|
||||
|
||||
|
||||
See also
|
||||
--------
|
||||
|
||||
|Macros|, |Configuration|, |BOOST_MPL_HAS_XXX_TEMPLATE_DEF|, |BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF|
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
.. Macros/Introspection//BOOST_MPL_HAS_XXX_TEMPLATE_DEF
|
||||
|
||||
.. Copyright Daniel Walker 2007.
|
||||
.. 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)
|
||||
|
||||
BOOST_MPL_HAS_XXX_TEMPLATE_DEF
|
||||
==============================
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
#define BOOST_MPL_HAS_XXX_TEMPLATE_DEF(name) \\
|
||||
|unspecified-token-seq| \\
|
||||
/\*\*/
|
||||
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
Expands into the definition of a boolean |Metafunction| ``has_name``
|
||||
such that for any type ``x`` ``has_name<x>::value == true`` if and
|
||||
only if ``x`` is a class type and has a nested template member
|
||||
``x::template name`` with no more than
|
||||
|BOOST_MPL_LIMIT_METAFUNCTION_ARITY| parameters.
|
||||
|
||||
On deficient compilers not capable of performing the detection,
|
||||
``has_name<x>::value`` is always ``false``. A boolean configuration
|
||||
macro, |BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE|, is provided to signal or
|
||||
override the "deficient" status of a particular compiler.
|
||||
|
||||
|Note:| |BOOST_MPL_HAS_XXX_TEMPLATE_DEF| is a simplified front end to
|
||||
the |BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF| introspection macro |-- end
|
||||
note|
|
||||
|
||||
|
||||
Header
|
||||
------
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
#include <boost/mpl/has_xxx.hpp>
|
||||
|
||||
|
||||
Parameters
|
||||
----------
|
||||
|
||||
|
||||
+---------------+-------------------------------+---------------------------------------------------+
|
||||
| Parameter | Requirement | Description |
|
||||
+===============+===============================+===================================================+
|
||||
| ``name`` | A legal identifier token | A name of the template member being detected. |
|
||||
+---------------+-------------------------------+---------------------------------------------------+
|
||||
|
||||
|
||||
Expression semantics
|
||||
--------------------
|
||||
|
||||
For any legal C++ identifier ``name``:
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
BOOST_MPL_HAS_XXX_TEMPLATE_DEF(name)
|
||||
|
||||
:Precondition:
|
||||
Appears at namespace scope.
|
||||
|
||||
:Return type:
|
||||
None.
|
||||
|
||||
:Semantics:
|
||||
Equivalent to
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF(
|
||||
BOOST_PP_CAT(has\_,name), name, false
|
||||
)
|
||||
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
BOOST_MPL_HAS_XXX_TEMPLATE_DEF(xxx)
|
||||
|
||||
struct test1 {};
|
||||
struct test2 { void xxx(); };
|
||||
struct test3 { int xxx; };
|
||||
struct test4 { static int xxx(); };
|
||||
struct test5 { typedef int xxx; };
|
||||
struct test6 { struct xxx; };
|
||||
struct test7 { typedef void (\*xxx)(); };
|
||||
struct test8 { typedef void (xxx)(); };
|
||||
struct test9 { template< class T > struct xxx {}; };
|
||||
|
||||
BOOST_MPL_ASSERT_NOT(( has_xxx<test1> ));
|
||||
BOOST_MPL_ASSERT_NOT(( has_xxx<test2> ));
|
||||
BOOST_MPL_ASSERT_NOT(( has_xxx<test3> ));
|
||||
BOOST_MPL_ASSERT_NOT(( has_xxx<test4> ));
|
||||
BOOST_MPL_ASSERT_NOT(( has_xxx<test5> ));
|
||||
BOOST_MPL_ASSERT_NOT(( has_xxx<test6> ));
|
||||
BOOST_MPL_ASSERT_NOT(( has_xxx<test7> ));
|
||||
BOOST_MPL_ASSERT_NOT(( has_xxx<test8> ));
|
||||
|
||||
#if !defined(BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE)
|
||||
BOOST_MPL_ASSERT(( has_xxx<test9> ));
|
||||
#endif
|
||||
|
||||
BOOST_MPL_ASSERT(( has_xxx<test9, true\_> ));
|
||||
|
||||
|
||||
See also
|
||||
--------
|
||||
|
||||
|Macros|, |BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF|,
|
||||
|BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE|, |BOOST_MPL_LIMIT_METAFUNCTION_ARITY|
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
.. Macros/Introspection//BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF
|
||||
|
||||
.. Copyright Daniel Walker 2007.
|
||||
.. 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)
|
||||
|
||||
BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF
|
||||
====================================
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
#define BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF(trait, name, default\_) \\
|
||||
|unspecified-token-seq| \\
|
||||
/\*\*/
|
||||
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
Expands into the definition of a boolean |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 template member ``x::template
|
||||
name`` with no more than |BOOST_MPL_LIMIT_METAFUNCTION_ARITY|
|
||||
parameters.
|
||||
|
||||
On deficient compilers not capable of performing the detection,
|
||||
``trait<x>::value`` always returns a fallback value ``default_``. A
|
||||
boolean configuration macro, |BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE|, 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|
|
||||
|
||||
|
||||
Header
|
||||
------
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
#include <boost/mpl/has_xxx.hpp>
|
||||
|
||||
|
||||
Parameters
|
||||
----------
|
||||
|
||||
+---------------+-------------------------------+---------------------------------------------------+
|
||||
| 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. |
|
||||
+---------------+-------------------------------+---------------------------------------------------+
|
||||
|
||||
|
||||
Expression semantics
|
||||
--------------------
|
||||
|
||||
For any legal C++ identifiers ``trait`` and ``name``, boolean constant
|
||||
expression ``c1``, boolean |Integral Constant| ``c2``, and arbitrary
|
||||
type ``x``:
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF(trait, name, c1)
|
||||
|
||||
:Precondition:
|
||||
Appears at namespace scope.
|
||||
|
||||
:Return type:
|
||||
None.
|
||||
|
||||
:Semantics:
|
||||
Expands into an equivalent of the following class template
|
||||
definition
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
template<
|
||||
typename X
|
||||
, typename fallback = boost::mpl::bool\_<c1>
|
||||
>
|
||||
struct trait
|
||||
{
|
||||
// |unspecified|
|
||||
// ...
|
||||
};
|
||||
|
||||
where ``trait`` is a boolean |Metafunction| with the following
|
||||
semantics:
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
typedef trait<x>::type r;
|
||||
|
||||
:Return type:
|
||||
|Integral Constant|.
|
||||
|
||||
:Semantics:
|
||||
If |BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE| is defined, ``r::value
|
||||
== c1``; otherwise, ``r::value == true`` if and only if ``x``
|
||||
is a class type that has a nested template member ``x::template
|
||||
name`` with no more than |BOOST_MPL_LIMIT_METAFUNCTION_ARITY|.
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
typedef trait< x, c2 >::type r;
|
||||
|
||||
:Return type:
|
||||
|Integral Constant|.
|
||||
|
||||
:Semantics:
|
||||
If |BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE| is defined, ``r::value
|
||||
== c2::value``; otherwise, equivalent to
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
typedef trait<x>::type r;
|
||||
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF(
|
||||
has_xxx, xxx, false
|
||||
)
|
||||
|
||||
struct test1 {};
|
||||
struct test2 { void xxx(); };
|
||||
struct test3 { int xxx; };
|
||||
struct test4 { static int xxx(); };
|
||||
struct test5 { typedef int xxx; };
|
||||
struct test6 { struct xxx; };
|
||||
struct test7 { typedef void (\*xxx)(); };
|
||||
struct test8 { typedef void (xxx)(); };
|
||||
struct test9 { template< class T > struct xxx {}; };
|
||||
|
||||
BOOST_MPL_ASSERT_NOT(( has_xxx<test1> ));
|
||||
BOOST_MPL_ASSERT_NOT(( has_xxx<test2> ));
|
||||
BOOST_MPL_ASSERT_NOT(( has_xxx<test3> ));
|
||||
BOOST_MPL_ASSERT_NOT(( has_xxx<test4> ));
|
||||
BOOST_MPL_ASSERT_NOT(( has_xxx<test5> ));
|
||||
BOOST_MPL_ASSERT_NOT(( has_xxx<test6> ));
|
||||
BOOST_MPL_ASSERT_NOT(( has_xxx<test7> ));
|
||||
BOOST_MPL_ASSERT_NOT(( has_xxx<test8> ));
|
||||
|
||||
#if !defined(BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE)
|
||||
BOOST_MPL_ASSERT(( has_xxx<test9> ));
|
||||
#endif
|
||||
|
||||
BOOST_MPL_ASSERT(( has_xxx<test9, true\_> ));
|
||||
|
||||
|
||||
See also
|
||||
--------
|
||||
|
||||
|Macros|, |BOOST_MPL_HAS_XXX_TEMPLATE_DEF|,
|
||||
|BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE|, |BOOST_MPL_LIMIT_METAFUNCTION_ARITY|
|
||||
|
||||
@@ -103,7 +103,7 @@ For any |Forward Sequence| ``s``, |Lambda Expression| ``op`` , and an
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
for_each< tranform_view<s,op> >( f );
|
||||
for_each< transform_view<s,op> >( f );
|
||||
|
||||
|
||||
Complexity
|
||||
@@ -121,7 +121,7 @@ Example
|
||||
{
|
||||
template< typename U > void operator()(U x)
|
||||
{
|
||||
std::cout << x << '\n';
|
||||
std::cout << x << '\\n';
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -81,25 +81,22 @@ Example
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
FIXME
|
||||
|
||||
struct f
|
||||
{
|
||||
template< typename T1, typename T2 > struct apply
|
||||
{
|
||||
// |...|
|
||||
typedef T2 type;
|
||||
};
|
||||
};
|
||||
|
||||
typedef bind<_1, protect< bind<f,_1,_2> > >
|
||||
|
||||
typedef apply_wrap0< f0 >::type r1;
|
||||
typedef apply_wrap0< g0 >::type r2;
|
||||
typedef apply_wrap2< f2,int,char >::type r3;
|
||||
|
||||
|
||||
typedef bind< quote\ ``3``\<if\_>,_1,_2,bind<f,_1,_2> > b1;
|
||||
typedef bind< quote\ ``3``\<if\_>,_1,_2,protect< bind<f,_1,_2> > > b2;
|
||||
|
||||
typedef apply_wrap\ ``2``\< b1,false\_,char >::type r1;
|
||||
typedef apply_wrap\ ``2``\< b2,false\_,char >::type r2;
|
||||
|
||||
BOOST_MPL_ASSERT(( is_same<r1,char> ));
|
||||
BOOST_MPL_ASSERT(( is_same<r2,char> ));
|
||||
BOOST_MPL_ASSERT(( is_same<r3,char> ));
|
||||
BOOST_MPL_ASSERT(( is_same<r2,protect< bind<f,_1,_2> > > ));
|
||||
|
||||
|
||||
See also
|
||||
|
||||
Executable → Regular
Executable → Regular
@@ -27,6 +27,7 @@
|
||||
)
|
||||
|
||||
# define BOOST_MPL_CFG_NO_HAS_XXX
|
||||
# define BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -6,11 +6,10 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
// Preprocessed version of "boost/mpl/aux_/template_arity.hpp" header
|
||||
// *Preprocessed* version of the main "template_arity.hpp" header
|
||||
// -- DO NOT modify by hand!
|
||||
|
||||
namespace boost { namespace mpl { namespace aux {
|
||||
|
||||
template< int N > struct arity_tag
|
||||
{
|
||||
typedef char (&type)[N + 1];
|
||||
@@ -23,7 +22,6 @@ struct max_arity
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(int, value =
|
||||
( C6 > 0 ? C6 : ( C5 > 0 ? C5 : ( C4 > 0 ? C4 : ( C3 > 0 ? C3 : ( C2 > 0 ? C2 : ( C1 > 0 ? C1 : -1 ) ) ) ) ) )
|
||||
|
||||
);
|
||||
};
|
||||
|
||||
@@ -83,7 +81,7 @@ template< typename F, int N >
|
||||
struct template_arity_impl
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(int, value =
|
||||
sizeof(arity_helper(type_wrapper<F>(), arity_tag<N>())) - 1
|
||||
sizeof(::boost::mpl::aux::arity_helper(type_wrapper<F>(), arity_tag<N>())) - 1
|
||||
);
|
||||
};
|
||||
|
||||
@@ -92,9 +90,7 @@ struct template_arity
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(int, value = (
|
||||
max_arity< template_arity_impl< F,1 >::value, template_arity_impl< F,2 >::value, template_arity_impl< F,3 >::value, template_arity_impl< F,4 >::value, template_arity_impl< F,5 >::value, template_arity_impl< F,6 >::value >::value
|
||||
|
||||
));
|
||||
|
||||
typedef mpl::int_<value> type;
|
||||
};
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ template< typename F, BOOST_MPL_AUX_NTTP_DECL(int, N) >
|
||||
struct template_arity_impl
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(int, value =
|
||||
sizeof(arity_helper(type_wrapper<F>(),arity_tag<N>())) - 1
|
||||
sizeof(::boost::mpl::aux::arity_helper(type_wrapper<F>(),arity_tag<N>())) - 1
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#ifndef BOOST_MPL_BITAND_HPP_INCLUDED
|
||||
#define BOOST_MPL_BITAND_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
// Copyright Aleksey Gurtovoy 2000-2009
|
||||
// Copyright Jaap Suter 2003
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
@@ -15,9 +15,31 @@
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
// agurt, 23/jan/10: workaround a conflict with <iso646.h> header's
|
||||
// macros, see http://tinyurl.com/ycwdxco; 'defined(bitand)'
|
||||
// has to be checked in a separate condition, otherwise GCC complains
|
||||
// about 'bitand' being an alternative token
|
||||
#if defined(_MSC_VER)
|
||||
#ifndef __GCCXML__
|
||||
#if defined(bitand)
|
||||
# pragma push_macro("bitand")
|
||||
# undef bitand
|
||||
# define bitand(x)
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define AUX778076_OP_NAME bitand_
|
||||
#define AUX778076_OP_PREFIX bitand
|
||||
#define AUX778076_OP_TOKEN &
|
||||
#include <boost/mpl/aux_/arithmetic_op.hpp>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#ifndef __GCCXML__
|
||||
#if defined(bitand)
|
||||
# pragma pop_macro("bitand")
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // BOOST_MPL_BITAND_HPP_INCLUDED
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#ifndef BOOST_MPL_BITOR_HPP_INCLUDED
|
||||
#define BOOST_MPL_BITOR_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
// Copyright Aleksey Gurtovoy 2000-2009
|
||||
// Copyright Jaap Suter 2003
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
@@ -15,9 +15,31 @@
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
// agurt, 23/jan/10: workaround a conflict with <iso646.h> header's
|
||||
// macros, see http://tinyurl.com/ycwdxco; 'defined(bitor)'
|
||||
// has to be checked in a separate condition, otherwise GCC complains
|
||||
// about 'bitor' being an alternative token
|
||||
#if defined(_MSC_VER)
|
||||
#ifndef __GCCXML__
|
||||
#if defined(bitor)
|
||||
# pragma push_macro("bitor")
|
||||
# undef bitor
|
||||
# define bitor(x)
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define AUX778076_OP_NAME bitor_
|
||||
#define AUX778076_OP_PREFIX bitor
|
||||
#define AUX778076_OP_TOKEN |
|
||||
#include <boost/mpl/aux_/arithmetic_op.hpp>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#ifndef __GCCXML__
|
||||
#if defined(bitor)
|
||||
# pragma pop_macro("bitor")
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // BOOST_MPL_BITOR_HPP_INCLUDED
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2002-2006
|
||||
// Copyright David Abrahams 2002-2003
|
||||
// Copyright Daniel Walker 2007
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -16,15 +17,21 @@
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/aux_/na_spec.hpp>
|
||||
#include <boost/mpl/aux_/type_wrapper.hpp>
|
||||
#include <boost/mpl/aux_/yes_no.hpp>
|
||||
#include <boost/mpl/aux_/config/gcc.hpp>
|
||||
#include <boost/mpl/aux_/config/has_xxx.hpp>
|
||||
#include <boost/mpl/aux_/config/msvc_typename.hpp>
|
||||
#include <boost/mpl/aux_/config/msvc.hpp>
|
||||
#include <boost/mpl/aux_/config/static_constant.hpp>
|
||||
#include <boost/mpl/aux_/config/workaround.hpp>
|
||||
|
||||
#include <boost/preprocessor/array/elem.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/control/if.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_trailing_params.hpp>
|
||||
|
||||
#if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x590) )
|
||||
# include <boost/type_traits/is_class.hpp>
|
||||
@@ -271,4 +278,363 @@ struct trait \
|
||||
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(BOOST_PP_CAT(has_,name), name, false) \
|
||||
/**/
|
||||
|
||||
|
||||
#if !defined(BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE)
|
||||
|
||||
// Create a boolean Metafunction to detect a nested template
|
||||
// member. This implementation is based on a USENET newsgroup's
|
||||
// posting by Aleksey Gurtovoy (comp.lang.c++.moderated, 2002-03-19),
|
||||
// Rani Sharoni's USENET posting cited above, the non-template has_xxx
|
||||
// implementations above, and discussion on the Boost mailing list.
|
||||
|
||||
# if !defined(BOOST_MPL_HAS_XXX_NO_WRAPPED_TYPES)
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, <= 1400)
|
||||
# define BOOST_MPL_HAS_XXX_NO_WRAPPED_TYPES 1
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# if !defined(BOOST_MPL_HAS_XXX_NO_EXPLICIT_TEST_FUNCTION)
|
||||
# if (defined(BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS))
|
||||
# define BOOST_MPL_HAS_XXX_NO_EXPLICIT_TEST_FUNCTION 1
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# if !defined(BOOST_MPL_HAS_XXX_NEEDS_TEMPLATE_SFINAE)
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, <= 1400)
|
||||
# define BOOST_MPL_HAS_XXX_NEEDS_TEMPLATE_SFINAE 1
|
||||
# endif
|
||||
# endif
|
||||
|
||||
// NOTE: Many internal implementation macros take a Boost.Preprocessor
|
||||
// array argument called args which is of the following form.
|
||||
// ( 4, ( trait, name, max_arity, default_ ) )
|
||||
|
||||
# define BOOST_MPL_HAS_MEMBER_INTROSPECTION_NAME(args) \
|
||||
BOOST_PP_CAT(BOOST_PP_ARRAY_ELEM(0, args) , _introspect) \
|
||||
/**/
|
||||
|
||||
# define BOOST_MPL_HAS_MEMBER_INTROSPECTION_SUBSTITUTE_NAME(args, n) \
|
||||
BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_ARRAY_ELEM(0, args) , _substitute), n) \
|
||||
/**/
|
||||
|
||||
# define BOOST_MPL_HAS_MEMBER_INTROSPECTION_TEST_NAME(args) \
|
||||
BOOST_PP_CAT(BOOST_PP_ARRAY_ELEM(0, args) , _test) \
|
||||
/**/
|
||||
|
||||
// Thanks to Guillaume Melquiond for pointing out the need for the
|
||||
// "substitute" template as an argument to the overloaded test
|
||||
// functions to get SFINAE to work for member templates with the
|
||||
// correct name but different number of arguments.
|
||||
# define BOOST_MPL_HAS_MEMBER_MULTI_SUBSTITUTE(z, n, args) \
|
||||
template< \
|
||||
template< BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n), typename V) > class V \
|
||||
> \
|
||||
struct BOOST_MPL_HAS_MEMBER_INTROSPECTION_SUBSTITUTE_NAME(args, n) { \
|
||||
}; \
|
||||
/**/
|
||||
|
||||
# define BOOST_MPL_HAS_MEMBER_SUBSTITUTE(args, substitute_macro) \
|
||||
BOOST_PP_REPEAT( \
|
||||
BOOST_PP_ARRAY_ELEM(2, args) \
|
||||
, BOOST_MPL_HAS_MEMBER_MULTI_SUBSTITUTE \
|
||||
, args \
|
||||
) \
|
||||
/**/
|
||||
|
||||
# if !BOOST_MPL_HAS_XXX_NO_EXPLICIT_TEST_FUNCTION
|
||||
# define BOOST_MPL_HAS_MEMBER_REJECT(args, member_macro) \
|
||||
template< typename V > \
|
||||
static boost::mpl::aux::no_tag \
|
||||
BOOST_MPL_HAS_MEMBER_INTROSPECTION_TEST_NAME(args)(...); \
|
||||
/**/
|
||||
# else
|
||||
# define BOOST_MPL_HAS_MEMBER_REJECT(args, member_macro) \
|
||||
static boost::mpl::aux::no_tag \
|
||||
BOOST_MPL_HAS_MEMBER_INTROSPECTION_TEST_NAME(args)(...); \
|
||||
/**/
|
||||
# endif
|
||||
|
||||
# if !BOOST_MPL_HAS_XXX_NO_WRAPPED_TYPES
|
||||
# define BOOST_MPL_HAS_MEMBER_MULTI_ACCEPT(z, n, args) \
|
||||
template< typename V > \
|
||||
static boost::mpl::aux::yes_tag \
|
||||
BOOST_MPL_HAS_MEMBER_INTROSPECTION_TEST_NAME(args)( \
|
||||
boost::mpl::aux::type_wrapper< V > const volatile* \
|
||||
, BOOST_MPL_HAS_MEMBER_INTROSPECTION_SUBSTITUTE_NAME(args, n) < \
|
||||
V::template BOOST_PP_ARRAY_ELEM(1, args) \
|
||||
>* = 0 \
|
||||
); \
|
||||
/**/
|
||||
# define BOOST_MPL_HAS_MEMBER_ACCEPT(args, member_macro) \
|
||||
BOOST_PP_REPEAT( \
|
||||
BOOST_PP_ARRAY_ELEM(2, args) \
|
||||
, BOOST_MPL_HAS_MEMBER_MULTI_ACCEPT \
|
||||
, args \
|
||||
) \
|
||||
/**/
|
||||
# else
|
||||
# define BOOST_MPL_HAS_MEMBER_ACCEPT(args, member_macro) \
|
||||
template< typename V > \
|
||||
static boost::mpl::aux::yes_tag \
|
||||
BOOST_MPL_HAS_MEMBER_INTROSPECTION_TEST_NAME(args)( \
|
||||
V const volatile* \
|
||||
, member_macro(args, V, T)* = 0 \
|
||||
); \
|
||||
/**/
|
||||
# endif
|
||||
|
||||
# if !BOOST_MPL_HAS_XXX_NO_EXPLICIT_TEST_FUNCTION
|
||||
# define BOOST_MPL_HAS_MEMBER_TEST(args) \
|
||||
sizeof(BOOST_MPL_HAS_MEMBER_INTROSPECTION_TEST_NAME(args)< U >(0)) \
|
||||
== sizeof(boost::mpl::aux::yes_tag) \
|
||||
/**/
|
||||
# else
|
||||
# if !BOOST_MPL_HAS_XXX_NO_WRAPPED_TYPES
|
||||
# define BOOST_MPL_HAS_MEMBER_TEST(args) \
|
||||
sizeof( \
|
||||
BOOST_MPL_HAS_MEMBER_INTROSPECTION_TEST_NAME(args)( \
|
||||
static_cast< boost::mpl::aux::type_wrapper< U >* >(0) \
|
||||
) \
|
||||
) == sizeof(boost::mpl::aux::yes_tag) \
|
||||
/**/
|
||||
# else
|
||||
# define BOOST_MPL_HAS_MEMBER_TEST(args) \
|
||||
sizeof( \
|
||||
BOOST_MPL_HAS_MEMBER_INTROSPECTION_TEST_NAME(args)( \
|
||||
static_cast< U* >(0) \
|
||||
) \
|
||||
) == sizeof(boost::mpl::aux::yes_tag) \
|
||||
/**/
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# define BOOST_MPL_HAS_MEMBER_INTROSPECT( \
|
||||
args, substitute_macro, member_macro \
|
||||
) \
|
||||
template< typename U > \
|
||||
struct BOOST_MPL_HAS_MEMBER_INTROSPECTION_NAME(args) { \
|
||||
BOOST_MPL_HAS_MEMBER_SUBSTITUTE(args, substitute_macro) \
|
||||
BOOST_MPL_HAS_MEMBER_REJECT(args, member_macro) \
|
||||
BOOST_MPL_HAS_MEMBER_ACCEPT(args, member_macro) \
|
||||
BOOST_STATIC_CONSTANT( \
|
||||
bool, value = BOOST_MPL_HAS_MEMBER_TEST(args) \
|
||||
); \
|
||||
typedef boost::mpl::bool_< value > type; \
|
||||
}; \
|
||||
/**/
|
||||
|
||||
# define BOOST_MPL_HAS_MEMBER_IMPLEMENTATION( \
|
||||
args, introspect_macro, substitute_macro, member_macro \
|
||||
) \
|
||||
template< \
|
||||
typename T \
|
||||
, typename fallback_ \
|
||||
= boost::mpl::bool_< BOOST_PP_ARRAY_ELEM(3, args) > \
|
||||
> \
|
||||
class BOOST_PP_ARRAY_ELEM(0, args) { \
|
||||
introspect_macro(args, substitute_macro, member_macro) \
|
||||
public: \
|
||||
static const bool value \
|
||||
= BOOST_MPL_HAS_MEMBER_INTROSPECTION_NAME(args)< T >::value; \
|
||||
typedef typename BOOST_MPL_HAS_MEMBER_INTROSPECTION_NAME(args)< \
|
||||
T \
|
||||
>::type type; \
|
||||
}; \
|
||||
/**/
|
||||
|
||||
// BOOST_MPL_HAS_MEMBER_WITH_FUNCTION_SFINAE expands to the full
|
||||
// implementation of the function-based metafunction. Compile with -E
|
||||
// to see the preprocessor output for this macro.
|
||||
# define BOOST_MPL_HAS_MEMBER_WITH_FUNCTION_SFINAE( \
|
||||
args, substitute_macro, member_macro \
|
||||
) \
|
||||
BOOST_MPL_HAS_MEMBER_IMPLEMENTATION( \
|
||||
args \
|
||||
, BOOST_MPL_HAS_MEMBER_INTROSPECT \
|
||||
, substitute_macro \
|
||||
, member_macro \
|
||||
) \
|
||||
/**/
|
||||
|
||||
# if BOOST_MPL_HAS_XXX_NEEDS_TEMPLATE_SFINAE
|
||||
|
||||
# if !defined(BOOST_MPL_HAS_XXX_NEEDS_NAMESPACE_LEVEL_SUBSTITUTE)
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, <= 1400)
|
||||
# define BOOST_MPL_HAS_XXX_NEEDS_NAMESPACE_LEVEL_SUBSTITUTE 1
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# if !BOOST_MPL_HAS_XXX_NEEDS_NAMESPACE_LEVEL_SUBSTITUTE
|
||||
# define BOOST_MPL_HAS_MEMBER_INTROSPECTION_SUBSTITUTE_NAME_WITH_TEMPLATE_SFINAE( \
|
||||
args, n \
|
||||
) \
|
||||
BOOST_MPL_HAS_MEMBER_INTROSPECTION_SUBSTITUTE_NAME(args, n) \
|
||||
/**/
|
||||
# else
|
||||
# define BOOST_MPL_HAS_MEMBER_INTROSPECTION_SUBSTITUTE_NAME_WITH_TEMPLATE_SFINAE( \
|
||||
args, n \
|
||||
) \
|
||||
BOOST_PP_CAT( \
|
||||
boost_mpl_has_xxx_ \
|
||||
, BOOST_MPL_HAS_MEMBER_INTROSPECTION_SUBSTITUTE_NAME(args, n) \
|
||||
) \
|
||||
/**/
|
||||
# endif
|
||||
|
||||
# define BOOST_MPL_HAS_MEMBER_INTROSPECTION_SUBSTITUTE_TAG_NAME( \
|
||||
args \
|
||||
) \
|
||||
BOOST_PP_CAT( \
|
||||
BOOST_MPL_HAS_MEMBER_INTROSPECTION_SUBSTITUTE_NAME_WITH_TEMPLATE_SFINAE( \
|
||||
args, 0 \
|
||||
) \
|
||||
, _tag \
|
||||
) \
|
||||
/**/
|
||||
|
||||
# define BOOST_MPL_HAS_MEMBER_MULTI_SUBSTITUTE_WITH_TEMPLATE_SFINAE( \
|
||||
z, n, args \
|
||||
) \
|
||||
template< \
|
||||
template< BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n), typename U) > class U \
|
||||
> \
|
||||
struct BOOST_MPL_HAS_MEMBER_INTROSPECTION_SUBSTITUTE_NAME_WITH_TEMPLATE_SFINAE( \
|
||||
args, n \
|
||||
) { \
|
||||
typedef \
|
||||
BOOST_MPL_HAS_MEMBER_INTROSPECTION_SUBSTITUTE_TAG_NAME(args) \
|
||||
type; \
|
||||
}; \
|
||||
/**/
|
||||
|
||||
# define BOOST_MPL_HAS_MEMBER_SUBSTITUTE_WITH_TEMPLATE_SFINAE( \
|
||||
args, substitute_macro \
|
||||
) \
|
||||
typedef void \
|
||||
BOOST_MPL_HAS_MEMBER_INTROSPECTION_SUBSTITUTE_TAG_NAME(args); \
|
||||
BOOST_PP_REPEAT( \
|
||||
BOOST_PP_ARRAY_ELEM(2, args) \
|
||||
, BOOST_MPL_HAS_MEMBER_MULTI_SUBSTITUTE_WITH_TEMPLATE_SFINAE \
|
||||
, args \
|
||||
) \
|
||||
/**/
|
||||
|
||||
# define BOOST_MPL_HAS_MEMBER_REJECT_WITH_TEMPLATE_SFINAE( \
|
||||
args, member_macro \
|
||||
) \
|
||||
template< \
|
||||
typename U \
|
||||
, typename V \
|
||||
= BOOST_MPL_HAS_MEMBER_INTROSPECTION_SUBSTITUTE_TAG_NAME(args) \
|
||||
> \
|
||||
struct BOOST_MPL_HAS_MEMBER_INTROSPECTION_TEST_NAME(args) { \
|
||||
BOOST_STATIC_CONSTANT(bool, value = false); \
|
||||
typedef boost::mpl::bool_< value > type; \
|
||||
}; \
|
||||
/**/
|
||||
|
||||
# define BOOST_MPL_HAS_MEMBER_MULTI_ACCEPT_WITH_TEMPLATE_SFINAE( \
|
||||
z, n, args \
|
||||
) \
|
||||
template< typename U > \
|
||||
struct BOOST_MPL_HAS_MEMBER_INTROSPECTION_TEST_NAME(args)< \
|
||||
U \
|
||||
, typename \
|
||||
BOOST_MPL_HAS_MEMBER_INTROSPECTION_SUBSTITUTE_NAME_WITH_TEMPLATE_SFINAE( \
|
||||
args, n \
|
||||
)< \
|
||||
BOOST_MSVC_TYPENAME U::BOOST_PP_ARRAY_ELEM(1, args)< > \
|
||||
>::type \
|
||||
> { \
|
||||
BOOST_STATIC_CONSTANT(bool, value = true); \
|
||||
typedef boost::mpl::bool_< value > type; \
|
||||
}; \
|
||||
/**/
|
||||
|
||||
# define BOOST_MPL_HAS_MEMBER_ACCEPT_WITH_TEMPLATE_SFINAE( \
|
||||
args, member_macro \
|
||||
) \
|
||||
BOOST_PP_REPEAT( \
|
||||
BOOST_PP_ARRAY_ELEM(2, args) \
|
||||
, BOOST_MPL_HAS_MEMBER_MULTI_ACCEPT_WITH_TEMPLATE_SFINAE \
|
||||
, args \
|
||||
) \
|
||||
/**/
|
||||
|
||||
# define BOOST_MPL_HAS_MEMBER_INTROSPECT_WITH_TEMPLATE_SFINAE( \
|
||||
args, substitute_macro, member_macro \
|
||||
) \
|
||||
BOOST_MPL_HAS_MEMBER_REJECT_WITH_TEMPLATE_SFINAE(args, member_macro) \
|
||||
BOOST_MPL_HAS_MEMBER_ACCEPT_WITH_TEMPLATE_SFINAE(args, member_macro) \
|
||||
template< typename U > \
|
||||
struct BOOST_MPL_HAS_MEMBER_INTROSPECTION_NAME(args) \
|
||||
: BOOST_MPL_HAS_MEMBER_INTROSPECTION_TEST_NAME(args)< U > { \
|
||||
}; \
|
||||
/**/
|
||||
|
||||
// BOOST_MPL_HAS_MEMBER_WITH_TEMPLATE_SFINAE expands to the full
|
||||
// implementation of the template-based metafunction. Compile with -E
|
||||
// to see the preprocessor output for this macro.
|
||||
//
|
||||
// Note that if BOOST_MPL_HAS_XXX_NEEDS_NAMESPACE_LEVEL_SUBSTITUTE is
|
||||
// defined BOOST_MPL_HAS_MEMBER_SUBSTITUTE_WITH_TEMPLATE_SFINAE needs
|
||||
// to be expanded at namespace level before
|
||||
// BOOST_MPL_HAS_MEMBER_WITH_TEMPLATE_SFINAE can be used.
|
||||
# define BOOST_MPL_HAS_MEMBER_WITH_TEMPLATE_SFINAE( \
|
||||
args, substitute_macro, member_macro \
|
||||
) \
|
||||
BOOST_MPL_HAS_MEMBER_SUBSTITUTE_WITH_TEMPLATE_SFINAE( \
|
||||
args, substitute_macro \
|
||||
) \
|
||||
BOOST_MPL_HAS_MEMBER_IMPLEMENTATION( \
|
||||
args \
|
||||
, BOOST_MPL_HAS_MEMBER_INTROSPECT_WITH_TEMPLATE_SFINAE \
|
||||
, substitute_macro \
|
||||
, member_macro \
|
||||
) \
|
||||
/**/
|
||||
|
||||
# endif // BOOST_MPL_HAS_XXX_NEEDS_TEMPLATE_SFINAE
|
||||
|
||||
// Note: In the current implementation the parameter and access macros
|
||||
// are no longer expanded.
|
||||
# if !BOOST_WORKAROUND(BOOST_MSVC, <= 1400)
|
||||
# define BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF(trait, name, default_) \
|
||||
BOOST_MPL_HAS_MEMBER_WITH_FUNCTION_SFINAE( \
|
||||
( 4, ( trait, name, BOOST_MPL_LIMIT_METAFUNCTION_ARITY, default_ ) ) \
|
||||
, BOOST_MPL_HAS_MEMBER_TEMPLATE_SUBSTITUTE_PARAMETER \
|
||||
, BOOST_MPL_HAS_MEMBER_TEMPLATE_ACCESS \
|
||||
) \
|
||||
/**/
|
||||
# else
|
||||
# define BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF(trait, name, default_) \
|
||||
BOOST_MPL_HAS_MEMBER_WITH_TEMPLATE_SFINAE( \
|
||||
( 4, ( trait, name, BOOST_MPL_LIMIT_METAFUNCTION_ARITY, default_ ) ) \
|
||||
, BOOST_MPL_HAS_MEMBER_TEMPLATE_SUBSTITUTE_PARAMETER \
|
||||
, BOOST_MPL_HAS_MEMBER_TEMPLATE_ACCESS \
|
||||
) \
|
||||
/**/
|
||||
# endif
|
||||
|
||||
#else // BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE
|
||||
|
||||
// placeholder implementation
|
||||
|
||||
# define BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF(trait, name, default_) \
|
||||
template< typename T \
|
||||
, typename fallback_ = boost::mpl::bool_< default_ > > \
|
||||
struct trait { \
|
||||
BOOST_STATIC_CONSTANT(bool, value = fallback_::value); \
|
||||
typedef fallback_ type; \
|
||||
}; \
|
||||
/**/
|
||||
|
||||
#endif // BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE
|
||||
|
||||
# define BOOST_MPL_HAS_XXX_TEMPLATE_DEF(name) \
|
||||
BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF( \
|
||||
BOOST_PP_CAT(has_, name), name, false \
|
||||
) \
|
||||
/**/
|
||||
|
||||
#endif // BOOST_MPL_HAS_XXX_HPP_INCLUDED
|
||||
|
||||
@@ -240,6 +240,18 @@ namespace boost { namespace mpl
|
||||
};
|
||||
};
|
||||
|
||||
template<typename Tag>
|
||||
struct has_push_back_impl;
|
||||
|
||||
template<>
|
||||
struct has_push_back_impl<mpl::string_tag>
|
||||
{
|
||||
template<typename Sequence>
|
||||
struct apply
|
||||
: mpl::true_
|
||||
{};
|
||||
};
|
||||
|
||||
template<typename Tag>
|
||||
struct pop_back_impl;
|
||||
|
||||
@@ -267,6 +279,18 @@ namespace boost { namespace mpl
|
||||
#undef M0
|
||||
};
|
||||
|
||||
template<typename Tag>
|
||||
struct has_pop_back_impl;
|
||||
|
||||
template<>
|
||||
struct has_pop_back_impl<mpl::string_tag>
|
||||
{
|
||||
template<typename Sequence>
|
||||
struct apply
|
||||
: mpl::true_
|
||||
{};
|
||||
};
|
||||
|
||||
template<typename Tag>
|
||||
struct push_front_impl;
|
||||
|
||||
@@ -341,6 +365,18 @@ namespace boost { namespace mpl
|
||||
};
|
||||
};
|
||||
|
||||
template<typename Tag>
|
||||
struct has_push_front_impl;
|
||||
|
||||
template<>
|
||||
struct has_push_front_impl<mpl::string_tag>
|
||||
{
|
||||
template<typename Sequence>
|
||||
struct apply
|
||||
: mpl::true_
|
||||
{};
|
||||
};
|
||||
|
||||
template<typename Tag>
|
||||
struct pop_front_impl;
|
||||
|
||||
@@ -375,6 +411,18 @@ namespace boost { namespace mpl
|
||||
};
|
||||
};
|
||||
|
||||
template<typename Tag>
|
||||
struct has_pop_front_impl;
|
||||
|
||||
template<>
|
||||
struct has_pop_front_impl<mpl::string_tag>
|
||||
{
|
||||
template<typename Sequence>
|
||||
struct apply
|
||||
: mpl::true_
|
||||
{};
|
||||
};
|
||||
|
||||
template<typename Tag>
|
||||
struct insert_range_impl;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#ifndef BOOST_MPL_ZIP_VIEW_HPP_INCLUDED
|
||||
#define BOOST_MPL_ZIP_VIEW_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2002
|
||||
// Copyright Aleksey Gurtovoy 2000-2010
|
||||
// Copyright David Abrahams 2000-2002
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
@@ -53,6 +53,7 @@ struct zip_view
|
||||
|
||||
public:
|
||||
typedef nested_begin_end_tag tag;
|
||||
typedef zip_view type;
|
||||
typedef zip_iterator<first_ones_> begin;
|
||||
typedef zip_iterator<last_ones_> end;
|
||||
};
|
||||
|
||||
Executable → Regular
@@ -1,5 +1,6 @@
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
// Copyright Daniel Walker 2007
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -16,6 +17,8 @@
|
||||
#include <boost/mpl/aux_/test.hpp>
|
||||
|
||||
BOOST_MPL_HAS_XXX_TRAIT_DEF(xxx)
|
||||
BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF(has_xxx_template, xxx, false)
|
||||
BOOST_MPL_HAS_XXX_TEMPLATE_DEF(yyy)
|
||||
|
||||
struct a1 {};
|
||||
struct a2 { void xxx(); };
|
||||
@@ -31,6 +34,14 @@ struct b5 { typedef int xxx[10]; };
|
||||
struct b6 { typedef void (*xxx)(); };
|
||||
struct b7 { typedef void (xxx)(); };
|
||||
|
||||
struct c1 { template< typename T > struct xxx {}; };
|
||||
struct c2 { template< typename T1, typename T2 > struct xxx {}; };
|
||||
struct c3 { template< typename T1, typename T2, typename T3 > struct xxx {}; };
|
||||
struct c4 { template< typename T1, typename T2, typename T3, typename T4 > struct xxx {}; };
|
||||
struct c5 { template< typename T1, typename T2, typename T3, typename T4, typename T5 > struct xxx {}; };
|
||||
struct c6 { template< typename T > struct yyy {}; };
|
||||
struct c7 { template< typename T1, typename T2 > struct yyy {}; };
|
||||
|
||||
template< typename T > struct outer;
|
||||
template< typename T > struct inner { typedef typename T::type type; };
|
||||
|
||||
@@ -42,25 +53,80 @@ template< typename T > struct xxx;
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
MPL_ASSERT_NOT(( has_xxx<int> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<int> ));
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
MPL_ASSERT_NOT(( has_xxx<int&> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<int&> ));
|
||||
|
||||
MPL_ASSERT_NOT(( has_xxx<int*> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<int*> ));
|
||||
|
||||
MPL_ASSERT_NOT(( has_xxx<int[]> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<int[]> ));
|
||||
|
||||
MPL_ASSERT_NOT(( has_xxx<int (*)()> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<int (*)()> ));
|
||||
|
||||
MPL_ASSERT_NOT(( has_xxx<a2> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<a2> ));
|
||||
|
||||
MPL_ASSERT_NOT(( has_xxx<a3> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<a3> ));
|
||||
|
||||
MPL_ASSERT_NOT(( has_xxx<a4> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<a4> ));
|
||||
|
||||
#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3202))
|
||||
MPL_ASSERT_NOT(( has_xxx<a5> ));
|
||||
MPL_ASSERT(( has_xxx_template<a5> ));
|
||||
#endif
|
||||
MPL_ASSERT_NOT(( has_xxx< enum_ > ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template< enum_ > ));
|
||||
#endif
|
||||
|
||||
MPL_ASSERT_NOT(( has_xxx<a1> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<a1> ));
|
||||
|
||||
MPL_ASSERT_NOT(( has_xxx< outer< inner<int> > > ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template< outer< inner<int> > > ));
|
||||
|
||||
MPL_ASSERT_NOT(( has_xxx< incomplete > ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template< incomplete > ));
|
||||
|
||||
MPL_ASSERT_NOT(( has_xxx< abstract > ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template< abstract > ));
|
||||
|
||||
MPL_ASSERT_NOT(( has_xxx< noncopyable > ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template< noncopyable > ));
|
||||
|
||||
#if !BOOST_WORKAROUND(__COMO_VERSION__, BOOST_TESTED_AT(4308))
|
||||
MPL_ASSERT_NOT(( has_xxx_template<b1> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<b2> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<b3> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<b4> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<b5> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<b6> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<b7> ));
|
||||
#endif
|
||||
|
||||
// Same name, different args.
|
||||
MPL_ASSERT(( has_xxx_template<c1> ));
|
||||
MPL_ASSERT(( has_xxx_template<c2> ));
|
||||
MPL_ASSERT(( has_xxx_template<c3> ));
|
||||
MPL_ASSERT(( has_xxx_template<c4> ));
|
||||
MPL_ASSERT(( has_xxx_template<c5> ));
|
||||
MPL_ASSERT(( has_yyy<c6> ));
|
||||
MPL_ASSERT(( has_yyy<c7> ));
|
||||
|
||||
// Different name, different args.
|
||||
MPL_ASSERT_NOT(( has_xxx_template<c6> ));
|
||||
MPL_ASSERT_NOT(( has_xxx_template<c7> ));
|
||||
MPL_ASSERT_NOT(( has_yyy<c1> ));
|
||||
MPL_ASSERT_NOT(( has_yyy<c2> ));
|
||||
MPL_ASSERT_NOT(( has_yyy<c3> ));
|
||||
MPL_ASSERT_NOT(( has_yyy<c4> ));
|
||||
MPL_ASSERT_NOT(( has_yyy<c5> ));
|
||||
|
||||
MPL_ASSERT(( has_xxx<b1,true_> ));
|
||||
MPL_ASSERT(( has_xxx<b2,true_> ));
|
||||
@@ -70,6 +136,8 @@ MPL_TEST_CASE()
|
||||
MPL_ASSERT(( has_xxx<b6,true_> ));
|
||||
MPL_ASSERT(( has_xxx<b7,true_> ));
|
||||
|
||||
MPL_ASSERT(( has_xxx_template<c1,true_> ));
|
||||
|
||||
#if !defined(HAS_XXX_ASSERT)
|
||||
# define HAS_XXX_ASSERT(x) MPL_ASSERT(x)
|
||||
#endif
|
||||
@@ -81,4 +149,10 @@ MPL_TEST_CASE()
|
||||
HAS_XXX_ASSERT(( has_xxx<b5> ));
|
||||
HAS_XXX_ASSERT(( has_xxx<b6> ));
|
||||
HAS_XXX_ASSERT(( has_xxx<b7> ));
|
||||
|
||||
#if !defined(HAS_XXX_TEMPLATE_ASSERT)
|
||||
# define HAS_XXX_TEMPLATE_ASSERT(x) MPL_ASSERT(x)
|
||||
#endif
|
||||
|
||||
HAS_XXX_TEMPLATE_ASSERT(( has_xxx_template<c1> ));
|
||||
}
|
||||
|
||||
@@ -23,4 +23,8 @@
|
||||
# define HAS_XXX_ASSERT(x) MPL_ASSERT_NOT(x)
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE)
|
||||
# define HAS_XXX_TEMPLATE_ASSERT(x) MPL_ASSERT_NOT(x)
|
||||
#endif
|
||||
|
||||
#include "has_xxx.cpp"
|
||||
|
||||
+5
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2002-2004
|
||||
// Copyright Aleksey Gurtovoy 2002-2010
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -25,6 +25,8 @@
|
||||
|
||||
#include <boost/mpl/aux_/test.hpp>
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
@@ -38,4 +40,6 @@ MPL_TEST_CASE()
|
||||
, filter_view< range_c<int,10,30>, is_even<_> >
|
||||
, equal_to<_,_>
|
||||
> ));
|
||||
|
||||
MPL_ASSERT(( boost::is_same< zip_view<vector<> >, zip_view<vector<> >::type > ));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user