1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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)
//
// See http://www.boost.org/libs/mpl for documentation.
// $Id$
// $Date$
// $Revision$
#include <boost/mpl/apply_wrap.hpp>
#include <boost/mpl/limits/arity.hpp>
#include <boost/mpl/aux_/preprocessor/params.hpp>
#include <boost/mpl/aux_/preprocessor/enum.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <boost/preprocessor/repeat.hpp>
#include <boost/preprocessor/comma_if.hpp>
#include <boost/preprocessor/dec.hpp>
#include <boost/preprocessor/if.hpp>
#include <boost/preprocessor/cat.hpp>
#if !defined(BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES)
# define APPLY_0_FUNC_DEF(i) \
struct f0 \
{ \
template< typename T = int > struct apply { typedef char type; }; \
}; \
/**/
#else
# define APPLY_0_FUNC_DEF(i) \
struct f0 \
{ \
template< typename T > struct apply { typedef char type; }; \
}; \
/**/
#endif
#define APPLY_N_FUNC_DEF(i) \
struct first##i \
{ \
template< BOOST_MPL_PP_PARAMS(i, typename U) > \
struct apply { typedef U1 type; }; \
}; \
\
struct last##i \
{ \
template< BOOST_MPL_PP_PARAMS(i, typename U) > \
struct apply { typedef BOOST_PP_CAT(U,i) type; }; \
}; \
/**/
#define APPLY_FUNC_DEF(z, i, unused) \
BOOST_PP_IF( \
i \
, APPLY_N_FUNC_DEF \
, APPLY_0_FUNC_DEF \
)(i) \
/**/
namespace { namespace test {
BOOST_PP_REPEAT(
BOOST_MPL_LIMIT_METAFUNCTION_ARITY
, APPLY_FUNC_DEF
, unused
)
struct g0 { struct apply { typedef char type; }; };
}}
#define APPLY_0_TEST(i, apply_) \
typedef apply_<test::f##i>::type t; \
{ MPL_ASSERT(( boost::is_same<t, char> )); } \
/**/
#define APPLY_N_TEST(i, apply_) \
typedef apply_< \
test::first##i \
, char \
BOOST_PP_COMMA_IF(BOOST_PP_DEC(i)) \
BOOST_MPL_PP_ENUM(BOOST_PP_DEC(i), int) \
>::type t1##i; \
\
typedef apply_< \
test::last##i \
, BOOST_MPL_PP_ENUM(BOOST_PP_DEC(i), int) \
BOOST_PP_COMMA_IF(BOOST_PP_DEC(i)) char \
>::type t2##i; \
{ MPL_ASSERT(( boost::is_same<t1##i, char> )); } \
{ MPL_ASSERT(( boost::is_same<t2##i, char> )); } \
/**/
#define APPLY_TEST(z, i, unused) \
BOOST_PP_IF( \
i \
, APPLY_N_TEST \
, APPLY_0_TEST \
)(i, BOOST_PP_CAT(apply_wrap,i)) \
/**/
MPL_TEST_CASE()
{
BOOST_PP_REPEAT(
BOOST_MPL_LIMIT_METAFUNCTION_ARITY
, APPLY_TEST
, unused
)
#if !defined(BOOST_MPL_CFG_NO_HAS_APPLY)
{
typedef apply_wrap0<test::g0>::type t;
MPL_ASSERT(( boost::is_same<t, char> ));
}
#endif
}
|