2 // Copyright Aleksey Gurtovoy 2000-2004
4 // Distributed under the Boost Software License, Version 1.0.
5 // (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
8 // See http://www.boost.org/libs/mpl for documentation.
14 #include <boost/mpl/apply_wrap.hpp>
15 #include <boost/mpl/limits/arity.hpp>
16 #include <boost/mpl/aux_/preprocessor/params.hpp>
17 #include <boost/mpl/aux_/preprocessor/enum.hpp>
18 #include <boost/mpl/aux_/test.hpp>
20 #include <boost/preprocessor/repeat.hpp>
21 #include <boost/preprocessor/comma_if.hpp>
22 #include <boost/preprocessor/dec.hpp>
23 #include <boost/preprocessor/if.hpp>
24 #include <boost/preprocessor/cat.hpp>
26 #if !defined(BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES)
27 # define APPLY_0_FUNC_DEF(i) \
30 template< typename T = int > struct apply { typedef char type; }; \
34 # define APPLY_0_FUNC_DEF(i) \
37 template< typename T > struct apply { typedef char type; }; \
42 #define APPLY_N_FUNC_DEF(i) \
45 template< BOOST_MPL_PP_PARAMS(i, typename U) > \
46 struct apply { typedef U1 type; }; \
51 template< BOOST_MPL_PP_PARAMS(i, typename U) > \
52 struct apply { typedef BOOST_PP_CAT(U,i) type; }; \
56 #define APPLY_FUNC_DEF(z, i, unused) \
64 namespace { namespace test
{
67 BOOST_MPL_LIMIT_METAFUNCTION_ARITY
72 struct g0
{ struct apply
{ typedef char type
; }; };
76 #define APPLY_0_TEST(i, apply_) \
77 typedef apply_<test::f##i>::type t; \
78 { MPL_ASSERT(( boost::is_same<t, char> )); } \
81 #define APPLY_N_TEST(i, apply_) \
85 BOOST_PP_COMMA_IF(BOOST_PP_DEC(i)) \
86 BOOST_MPL_PP_ENUM(BOOST_PP_DEC(i), int) \
91 , BOOST_MPL_PP_ENUM(BOOST_PP_DEC(i), int) \
92 BOOST_PP_COMMA_IF(BOOST_PP_DEC(i)) char \
94 { MPL_ASSERT(( boost::is_same<t1##i, char> )); } \
95 { MPL_ASSERT(( boost::is_same<t2##i, char> )); } \
98 #define APPLY_TEST(z, i, unused) \
103 )(i, BOOST_PP_CAT(apply_wrap,i)) \
110 BOOST_MPL_LIMIT_METAFUNCTION_ARITY
115 #if !defined(BOOST_MPL_CFG_NO_HAS_APPLY)
117 typedef apply_wrap0
<test::g0
>::type t
;
118 MPL_ASSERT(( boost::is_same
<t
, char> ));