2 // (C) Copyright Tobias Schwinger
4 // Use modification and distribution are subject to the boost Software License,
5 // Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt).
7 //------------------------------------------------------------------------------
9 // no include guards, this file is intended for multiple inclusion
11 #ifndef BOOST_FT_PREPROCESSING_MODE
12 // input: BOOST_FT_mfp 0 or 1 <=> member function pointer?
13 // input: BOOST_FT_type_name BOOST_FT_type --> "R (* ..._type_name)()" (pass2)
15 // input: BOOST_FT_syntax type macro to use
16 // input: BOOST_FT_cc empty or cc specifier
17 // input: BOOST_FT_ell empty or "..."
18 // input: BOOST_FT_cv empty or cv qualifiers
19 // input: BOOST_FT_flags single decimal integer encoding the flags
20 // output: BOOST_FT_n number of component types (arity+1)
21 // output: BOOST_FT_arity current arity
22 // output: BOOST_FT_type macro that expands to the type
23 // output: BOOST_FT_tplargs(p) template arguments with given prefix
24 // output: BOOST_FT_params(p) parameters with given prefix
27 # pragma wave option(preserve: 0)
30 #ifndef BOOST_FT_ARITY_LOOP_IS_ITERATING
32 # define BOOST_FT_AL_PREPROCESSED \
33 BOOST_FT_AL_FILE(BOOST_FT_al_path,BOOST_FT_FROM_ARITY,BOOST_FT_mfp)
35 # define BOOST_FT_AL_FILE(base_path,max_arity,mfp) \
36 BOOST_FT_AL_FILE_I(base_path,max_arity,mfp)
37 # define BOOST_FT_AL_FILE_I(base_path,max_arity,mfp) \
38 <base_path/arity ## max_arity ## _ ## mfp.hpp>
40 # if !defined(BOOST_FT_PREPROCESSING_MODE)
42 # if BOOST_FT_MAX_ARITY < 10
43 # define BOOST_FT_FROM_ARITY 0
44 # elif BOOST_FT_MAX_ARITY < 20
45 # define BOOST_FT_FROM_ARITY 10
46 # elif BOOST_FT_MAX_ARITY < 30
47 # define BOOST_FT_FROM_ARITY 20
48 # elif BOOST_FT_MAX_ARITY < 40
49 # define BOOST_FT_FROM_ARITY 30
52 # if BOOST_FT_FROM_ARITY
53 # include BOOST_FT_AL_PREPROCESSED
56 # elif !defined(BOOST_FT_FROM_ARITY) // single pass preprocessing
57 # define BOOST_FT_FROM_ARITY 0
59 # elif BOOST_FT_FROM_ARITY > 0 // arity20 includes arity10
60 BOOST_PP_EXPAND(#) include BOOST_FT_AL_PREPROCESSED
63 # undef BOOST_FT_AL_PREPROCESSED
65 # undef BOOST_FT_AL_FILE
66 # undef BOOST_FT_AL_FILE_I
68 # if BOOST_FT_MAX_ARITY > BOOST_FT_FROM_ARITY
70 # ifndef BOOST_FT_DETAIL_ARITY_LOOP_HPP_INCLUDED
71 # define BOOST_FT_DETAIL_ARITY_LOOP_HPP_INCLUDED
72 # include <boost/preprocessor/cat.hpp>
73 # include <boost/preprocessor/tuple/eat.hpp>
74 # include <boost/preprocessor/control/if.hpp>
75 # include <boost/preprocessor/arithmetic/inc.hpp>
76 # include <boost/preprocessor/facilities/empty.hpp>
77 # include <boost/preprocessor/facilities/expand.hpp>
78 # include <boost/preprocessor/iteration/iterate.hpp>
79 # include <boost/preprocessor/repetition/enum_params.hpp>
80 # include <boost/preprocessor/repetition/enum_shifted_params.hpp>
81 # include <boost/preprocessor/repetition/enum_trailing_params.hpp>
84 # define BOOST_FT_AL_INCLUDE_FILE <BOOST_FT_al_path/master.hpp>
86 # define BOOST_FT_ARITY_LOOP_PREFIX 1
87 # include BOOST_FT_AL_INCLUDE_FILE
88 # undef BOOST_FT_ARITY_LOOP_PREFIX
90 # if !BOOST_PP_IS_ITERATING
91 # define BOOST_PP_FILENAME_1 BOOST_FT_AL_INCLUDE_FILE
92 # elif BOOST_PP_ITERATION_DEPTH() == 1
93 # define BOOST_PP_FILENAME_2 BOOST_FT_AL_INCLUDE_FILE
95 # error "loops nested too deeply"
98 # define BOOST_FT_arity BOOST_PP_ITERATION()
99 # define BOOST_FT_n BOOST_PP_INC(BOOST_FT_arity)
101 # define BOOST_FT_type \
102 BOOST_FT_syntax(BOOST_FT_cc,BOOST_FT_type_name BOOST_PP_EMPTY)\
103 (BOOST_FT_params(BOOST_PP_EMPTY) BOOST_FT_ell) BOOST_FT_cv
105 # define BOOST_FT_tplargs(prefx) \
106 prefx() R BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_FT_arity,prefx() T)
110 # define BOOST_FT_params(prefx) \
111 BOOST_PP_IF(BOOST_FT_arity,BOOST_PP_ENUM_PARAMS, \
112 BOOST_FT_nullary_param BOOST_PP_TUPLE_EAT(2))( \
113 BOOST_FT_arity,prefx() T)
116 # define BOOST_FT_params(prefx) \
117 BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_FT_arity,prefx() T)
121 # if !BOOST_FT_FROM_ARITY
122 # define BOOST_PP_ITERATION_LIMITS (BOOST_FT_mfp, BOOST_FT_MAX_ARITY)
124 # define BOOST_PP_ITERATION_LIMITS \
125 (BOOST_FT_FROM_ARITY+1, BOOST_FT_MAX_ARITY)
128 # define BOOST_FT_ARITY_LOOP_IS_ITERATING 1
129 # include BOOST_PP_ITERATE()
130 # undef BOOST_FT_ARITY_LOOP_IS_ITERATING
132 # undef BOOST_FT_arity
133 # undef BOOST_FT_params
134 # undef BOOST_FT_tplargs
135 # undef BOOST_FT_type
137 # define BOOST_FT_ARITY_LOOP_SUFFIX 1
138 # include BOOST_FT_AL_INCLUDE_FILE
139 # undef BOOST_FT_ARITY_LOOP_SUFFIX
141 # undef BOOST_FT_AL_INCLUDE_FILE
144 # undef BOOST_FT_FROM_ARITY
147 # error "attempt to nest arity loops"