Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 1 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 2 | #if !defined(NDNBOOST_PP_IS_ITERATING) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 3 | |
| 4 | ///// header body |
| 5 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 6 | #ifndef NDNBOOST_MPL_APPLY_HPP_INCLUDED |
| 7 | #define NDNBOOST_MPL_APPLY_HPP_INCLUDED |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 8 | |
| 9 | // Copyright Aleksey Gurtovoy 2000-2004 |
| 10 | // |
| 11 | // Distributed under the Boost Software License, Version 1.0. |
| 12 | // (See accompanying file LICENSE_1_0.txt or copy at |
| 13 | // http://www.boost.org/LICENSE_1_0.txt) |
| 14 | // |
| 15 | // See http://www.boost.org/libs/mpl for documentation. |
| 16 | |
| 17 | // $Id: apply.hpp 49267 2008-10-11 06:19:02Z agurtovoy $ |
| 18 | // $Date: 2008-10-10 23:19:02 -0700 (Fri, 10 Oct 2008) $ |
| 19 | // $Revision: 49267 $ |
| 20 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 21 | #if !defined(NDNBOOST_MPL_PREPROCESSING_MODE) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 22 | # include <ndnboost/mpl/apply_fwd.hpp> |
| 23 | # include <ndnboost/mpl/apply_wrap.hpp> |
| 24 | # include <ndnboost/mpl/placeholders.hpp> |
| 25 | # include <ndnboost/mpl/lambda.hpp> |
| 26 | # include <ndnboost/mpl/aux_/na.hpp> |
| 27 | # include <ndnboost/mpl/aux_/lambda_support.hpp> |
| 28 | #endif |
| 29 | |
| 30 | #include <ndnboost/mpl/aux_/config/use_preprocessed.hpp> |
| 31 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 32 | #if !defined(NDNBOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \ |
| 33 | && !defined(NDNBOOST_MPL_PREPROCESSING_MODE) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 34 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 35 | # define NDNBOOST_MPL_PREPROCESSED_HEADER apply.hpp |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 36 | # include <ndnboost/mpl/aux_/include_preprocessed.hpp> |
| 37 | |
| 38 | #else |
| 39 | |
| 40 | # include <ndnboost/mpl/limits/arity.hpp> |
| 41 | # include <ndnboost/mpl/aux_/preprocessor/params.hpp> |
| 42 | # include <ndnboost/mpl/aux_/preprocessor/default_params.hpp> |
| 43 | # include <ndnboost/mpl/aux_/preprocessor/partial_spec_params.hpp> |
| 44 | # include <ndnboost/mpl/aux_/preprocessor/enum.hpp> |
| 45 | # include <ndnboost/mpl/aux_/config/lambda.hpp> |
| 46 | # include <ndnboost/mpl/aux_/config/dtp.hpp> |
| 47 | # include <ndnboost/mpl/aux_/nttp_decl.hpp> |
| 48 | # include <ndnboost/mpl/aux_/config/eti.hpp> |
| 49 | # include <ndnboost/mpl/aux_/config/msvc.hpp> |
| 50 | # include <ndnboost/mpl/aux_/config/workaround.hpp> |
| 51 | |
| 52 | # include <ndnboost/preprocessor/comma_if.hpp> |
| 53 | # include <ndnboost/preprocessor/inc.hpp> |
| 54 | # include <ndnboost/preprocessor/iterate.hpp> |
| 55 | # include <ndnboost/preprocessor/cat.hpp> |
| 56 | |
| 57 | namespace ndnboost { namespace mpl { |
| 58 | |
| 59 | // local macros, #undef-ined at the end of the header |
| 60 | # define AUX778076_APPLY_PARAMS(param) \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 61 | NDNBOOST_MPL_PP_PARAMS( \ |
| 62 | NDNBOOST_MPL_LIMIT_METAFUNCTION_ARITY \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 63 | , param \ |
| 64 | ) \ |
| 65 | /**/ |
| 66 | |
| 67 | # define AUX778076_APPLY_DEF_PARAMS(param, value) \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 68 | NDNBOOST_MPL_PP_DEFAULT_PARAMS( \ |
| 69 | NDNBOOST_MPL_LIMIT_METAFUNCTION_ARITY \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 70 | , param \ |
| 71 | , value \ |
| 72 | ) \ |
| 73 | /**/ |
| 74 | |
| 75 | # define AUX778076_APPLY_N_PARAMS(n, param) \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 76 | NDNBOOST_MPL_PP_PARAMS(n, param) \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 77 | /**/ |
| 78 | |
| 79 | # define AUX778076_APPLY_N_COMMA_PARAMS(n, param) \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 80 | NDNBOOST_PP_COMMA_IF(n) \ |
| 81 | NDNBOOST_MPL_PP_PARAMS(n, param) \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 82 | /**/ |
| 83 | |
| 84 | # define AUX778076_APPLY_N_PARTIAL_SPEC_PARAMS(n, param, def) \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 85 | NDNBOOST_PP_COMMA_IF(n) \ |
| 86 | NDNBOOST_MPL_PP_PARTIAL_SPEC_PARAMS(n, param, def) \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 87 | /**/ |
| 88 | |
| 89 | # define AUX778076_APPLY_N_SPEC_PARAMS(n, param) \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 90 | NDNBOOST_MPL_PP_ENUM(NDNBOOST_PP_INC(n), param) \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 91 | /**/ |
| 92 | |
| 93 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 94 | #define NDNBOOST_PP_ITERATION_PARAMS_1 \ |
| 95 | (3,(0, NDNBOOST_MPL_LIMIT_METAFUNCTION_ARITY, <ndnboost/mpl/apply.hpp>)) |
| 96 | #include NDNBOOST_PP_ITERATE() |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 97 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 98 | # if !defined(NDNBOOST_MPL_CFG_NO_APPLY_TEMPLATE) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 99 | // real C++ version is already taken care of |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 100 | # if defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 101 | |
| 102 | namespace aux { |
| 103 | // apply_count_args |
| 104 | #define AUX778076_COUNT_ARGS_PREFIX apply |
| 105 | #define AUX778076_COUNT_ARGS_DEFAULT na |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 106 | #define AUX778076_COUNT_ARGS_ARITY NDNBOOST_MPL_LIMIT_METAFUNCTION_ARITY |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 107 | #include <ndnboost/mpl/aux_/count_args.hpp> |
| 108 | } |
| 109 | |
| 110 | |
| 111 | template< |
| 112 | typename F, AUX778076_APPLY_DEF_PARAMS(typename T, na) |
| 113 | > |
| 114 | struct apply |
| 115 | : aux::apply_chooser< |
| 116 | aux::apply_count_args< AUX778076_APPLY_PARAMS(T) >::value |
| 117 | >::template result_< F, AUX778076_APPLY_PARAMS(T) >::type |
| 118 | { |
| 119 | }; |
| 120 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 121 | # endif // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
| 122 | # endif // NDNBOOST_MPL_CFG_NO_APPLY_TEMPLATE |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 123 | |
| 124 | # undef AUX778076_APPLY_N_SPEC_PARAMS |
| 125 | # undef AUX778076_APPLY_N_PARTIAL_SPEC_PARAMS |
| 126 | # undef AUX778076_APPLY_N_COMMA_PARAMS |
| 127 | # undef AUX778076_APPLY_N_PARAMS |
| 128 | # undef AUX778076_APPLY_DEF_PARAMS |
| 129 | # undef AUX778076_APPLY_PARAMS |
| 130 | |
| 131 | }} |
| 132 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 133 | #endif // NDNBOOST_MPL_CFG_NO_PREPROCESSED_HEADERS |
| 134 | #endif // NDNBOOST_MPL_APPLY_HPP_INCLUDED |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 135 | |
| 136 | ///// iteration, depth == 1 |
| 137 | |
| 138 | // For gcc 4.4 compatability, we must include the |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 139 | // NDNBOOST_PP_ITERATION_DEPTH test inside an #else clause. |
| 140 | #else // NDNBOOST_PP_IS_ITERATING |
| 141 | #if NDNBOOST_PP_ITERATION_DEPTH() == 1 |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 142 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 143 | # define i_ NDNBOOST_PP_FRAME_ITERATION(1) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 144 | |
| 145 | template< |
| 146 | typename F AUX778076_APPLY_N_COMMA_PARAMS(i_, typename T) |
| 147 | > |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 148 | struct NDNBOOST_PP_CAT(apply,i_) |
| 149 | #if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, < 1300) |
| 150 | : NDNBOOST_PP_CAT(apply_wrap,i_)< |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 151 | typename lambda<F>::type |
| 152 | AUX778076_APPLY_N_COMMA_PARAMS(i_, T) |
| 153 | > |
| 154 | { |
| 155 | #else |
| 156 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 157 | typedef typename NDNBOOST_PP_CAT(apply_wrap,i_)< |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 158 | typename lambda<F>::type |
| 159 | AUX778076_APPLY_N_COMMA_PARAMS(i_, T) |
| 160 | >::type type; |
| 161 | #endif |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 162 | NDNBOOST_MPL_AUX_LAMBDA_SUPPORT( |
| 163 | NDNBOOST_PP_INC(i_) |
| 164 | , NDNBOOST_PP_CAT(apply,i_) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 165 | , (F AUX778076_APPLY_N_COMMA_PARAMS(i_,T)) |
| 166 | ) |
| 167 | }; |
| 168 | |
| 169 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 170 | #if defined(NDNBOOST_MPL_CFG_MSVC_ETI_BUG) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 171 | /// workaround for ETI bug |
| 172 | template<> |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 173 | struct NDNBOOST_PP_CAT(apply,i_)<AUX778076_APPLY_N_SPEC_PARAMS(i_, int)> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 174 | { |
| 175 | typedef int type; |
| 176 | }; |
| 177 | #endif |
| 178 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 179 | # if !defined(NDNBOOST_MPL_CFG_NO_APPLY_TEMPLATE) |
| 180 | # if !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 181 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 182 | #if i_ == NDNBOOST_MPL_LIMIT_METAFUNCTION_ARITY |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 183 | /// primary template (not a specialization!) |
| 184 | template< |
| 185 | typename F AUX778076_APPLY_N_COMMA_PARAMS(i_, typename T) |
| 186 | > |
| 187 | struct apply |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 188 | : NDNBOOST_PP_CAT(apply,i_)< F AUX778076_APPLY_N_COMMA_PARAMS(i_, T) > |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 189 | { |
| 190 | }; |
| 191 | #else |
| 192 | template< |
| 193 | typename F AUX778076_APPLY_N_COMMA_PARAMS(i_, typename T) |
| 194 | > |
| 195 | struct apply< F AUX778076_APPLY_N_PARTIAL_SPEC_PARAMS(i_, T, na) > |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 196 | : NDNBOOST_PP_CAT(apply,i_)< F AUX778076_APPLY_N_COMMA_PARAMS(i_, T) > |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 197 | { |
| 198 | }; |
| 199 | #endif |
| 200 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 201 | # else // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 202 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 203 | #if !defined(NDNBOOST_MPL_CFG_NO_APPLY_TEMPLATE) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 204 | namespace aux { |
| 205 | |
| 206 | template<> |
| 207 | struct apply_chooser<i_> |
| 208 | { |
| 209 | template< |
| 210 | typename F, AUX778076_APPLY_PARAMS(typename T) |
| 211 | > |
| 212 | struct result_ |
| 213 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 214 | typedef NDNBOOST_PP_CAT(apply,i_)< |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 215 | F AUX778076_APPLY_N_COMMA_PARAMS(i_, T) |
| 216 | > type; |
| 217 | }; |
| 218 | }; |
| 219 | |
| 220 | } // namespace aux |
| 221 | #endif |
| 222 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 223 | # endif // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
| 224 | # endif // NDNBOOST_MPL_CFG_NO_APPLY_TEMPLATE |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 225 | |
| 226 | # undef i_ |
| 227 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 228 | #endif // NDNBOOST_PP_ITERATION_DEPTH() |
| 229 | #endif // NDNBOOST_PP_IS_ITERATING |