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_WRAP_HPP_INCLUDED |
| 7 | #define NDNBOOST_MPL_APPLY_WRAP_HPP_INCLUDED |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 8 | |
| 9 | // Copyright Aleksey Gurtovoy 2000-2008 |
| 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_wrap.hpp 49272 2008-10-11 06:50:46Z agurtovoy $ |
| 18 | // $Date: 2008-10-10 23:50:46 -0700 (Fri, 10 Oct 2008) $ |
| 19 | // $Revision: 49272 $ |
| 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/aux_/arity.hpp> |
| 23 | # include <ndnboost/mpl/aux_/has_apply.hpp> |
| 24 | # include <ndnboost/mpl/aux_/na.hpp> |
| 25 | # include <ndnboost/mpl/aux_/msvc_never_true.hpp> |
| 26 | #endif |
| 27 | |
| 28 | #include <ndnboost/mpl/aux_/config/use_preprocessed.hpp> |
| 29 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 30 | #if !defined(NDNBOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \ |
| 31 | && !defined(NDNBOOST_MPL_PREPROCESSING_MODE) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 32 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 33 | # define NDNBOOST_MPL_PREPROCESSED_HEADER apply_wrap.hpp |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 34 | # include <ndnboost/mpl/aux_/include_preprocessed.hpp> |
| 35 | |
| 36 | #else |
| 37 | |
| 38 | # include <ndnboost/mpl/limits/arity.hpp> |
| 39 | # include <ndnboost/mpl/aux_/preprocessor/params.hpp> |
| 40 | # include <ndnboost/mpl/aux_/preprocessor/enum.hpp> |
| 41 | # include <ndnboost/mpl/aux_/preprocessor/add.hpp> |
| 42 | # include <ndnboost/mpl/aux_/config/bcc.hpp> |
| 43 | # include <ndnboost/mpl/aux_/config/ctps.hpp> |
| 44 | # include <ndnboost/mpl/aux_/config/dtp.hpp> |
| 45 | # include <ndnboost/mpl/aux_/config/eti.hpp> |
| 46 | # include <ndnboost/mpl/aux_/config/msvc.hpp> |
| 47 | # include <ndnboost/mpl/aux_/config/workaround.hpp> |
| 48 | |
| 49 | # include <ndnboost/preprocessor/comma_if.hpp> |
| 50 | # include <ndnboost/preprocessor/logical/and.hpp> |
| 51 | # include <ndnboost/preprocessor/inc.hpp> |
| 52 | # include <ndnboost/preprocessor/iterate.hpp> |
| 53 | |
| 54 | |
| 55 | namespace ndnboost { namespace mpl { |
| 56 | |
| 57 | // local macros, #undef-ined at the end of the header |
| 58 | # define AUX778076_APPLY_WRAP_PARAMS(n, param) \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 59 | NDNBOOST_MPL_PP_PARAMS(n, param) \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 60 | /**/ |
| 61 | |
| 62 | # define AUX778076_APPLY_WRAP_SPEC_PARAMS(n, param) \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 63 | NDNBOOST_MPL_PP_ENUM(NDNBOOST_PP_INC(n), param) \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 64 | /**/ |
| 65 | |
| 66 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 67 | #define NDNBOOST_PP_ITERATION_PARAMS_1 \ |
| 68 | (3,(0, NDNBOOST_MPL_LIMIT_METAFUNCTION_ARITY, <ndnboost/mpl/apply_wrap.hpp>)) |
| 69 | #include NDNBOOST_PP_ITERATE() |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 70 | |
| 71 | |
| 72 | # undef AUX778076_APPLY_WRAP_SPEC_PARAMS |
| 73 | # undef AUX778076_APPLY_WRAP_PARAMS |
| 74 | |
| 75 | }} |
| 76 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 77 | #endif // NDNBOOST_MPL_CFG_NO_PREPROCESSED_HEADERS |
| 78 | #endif // NDNBOOST_MPL_APPLY_WRAP_HPP_INCLUDED |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 79 | |
| 80 | ///// iteration, depth == 1 |
| 81 | |
| 82 | // For gcc 4.4 compatability, we must include the |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 83 | // NDNBOOST_PP_ITERATION_DEPTH test inside an #else clause. |
| 84 | #else // NDNBOOST_PP_IS_ITERATING |
| 85 | #if NDNBOOST_PP_ITERATION_DEPTH() == 1 |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 86 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 87 | # define i_ NDNBOOST_PP_FRAME_ITERATION(1) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 88 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 89 | # if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, < 1300) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 90 | // MSVC version |
| 91 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 92 | #define AUX778076_MSVC_DTW_NAME NDNBOOST_PP_CAT(msvc_apply,i_) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 93 | #define AUX778076_MSVC_DTW_ORIGINAL_NAME apply |
| 94 | #define AUX778076_MSVC_DTW_ARITY i_ |
| 95 | #include <ndnboost/mpl/aux_/msvc_dtw.hpp> |
| 96 | |
| 97 | template< |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 98 | typename F NDNBOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 99 | > |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 100 | struct NDNBOOST_PP_CAT(apply_wrap,i_) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 101 | { |
| 102 | // Metafunction forwarding confuses vc6 |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 103 | typedef typename NDNBOOST_PP_CAT(msvc_apply,i_)<F>::template result_< |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 104 | AUX778076_APPLY_WRAP_PARAMS(i_, T) |
| 105 | >::type type; |
| 106 | }; |
| 107 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 108 | # elif defined(NDNBOOST_MPL_CFG_BROKEN_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 109 | // MWCW/Borland version |
| 110 | |
| 111 | template< |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 112 | int N, typename F NDNBOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 113 | > |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 114 | struct NDNBOOST_PP_CAT(apply_wrap_impl,i_); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 115 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 116 | #define NDNBOOST_PP_ITERATION_PARAMS_2 \ |
| 117 | (3,(0, NDNBOOST_MPL_LIMIT_METAFUNCTION_ARITY - i_, <ndnboost/mpl/apply_wrap.hpp>)) |
| 118 | #include NDNBOOST_PP_ITERATE() |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 119 | |
| 120 | template< |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 121 | typename F NDNBOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 122 | > |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 123 | struct NDNBOOST_PP_CAT(apply_wrap,i_) |
| 124 | : NDNBOOST_PP_CAT(apply_wrap_impl,i_)< |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 125 | ::ndnboost::mpl::aux::arity<F,i_>::value |
| 126 | , F |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 127 | NDNBOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, T) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 128 | >::type |
| 129 | { |
| 130 | }; |
| 131 | |
| 132 | # else |
| 133 | // ISO98 C++, with minor concession to vc7 |
| 134 | |
| 135 | template< |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 136 | typename F NDNBOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 137 | #if i_ == 0 |
| 138 | , typename has_apply_ = typename aux::has_apply<F>::type |
| 139 | #endif |
| 140 | > |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 141 | struct NDNBOOST_PP_CAT(apply_wrap,i_) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 142 | // metafunction forwarding confuses MSVC 7.0 |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 143 | #if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, == 1300) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 144 | : F::template apply< AUX778076_APPLY_WRAP_PARAMS(i_, T) > |
| 145 | { |
| 146 | #else |
| 147 | { |
| 148 | typedef typename F::template apply< |
| 149 | AUX778076_APPLY_WRAP_PARAMS(i_, T) |
| 150 | >::type type; |
| 151 | #endif |
| 152 | }; |
| 153 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 154 | #if i_ == 0 && !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 155 | template< typename F > |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 156 | struct NDNBOOST_PP_CAT(apply_wrap,i_)<F,true_> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 157 | : F::apply |
| 158 | { |
| 159 | }; |
| 160 | #endif |
| 161 | |
| 162 | # endif // workarounds |
| 163 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 164 | #if defined(NDNBOOST_MPL_CFG_MSVC_ETI_BUG) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 165 | /// workaround for ETI bug |
| 166 | template<> |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 167 | struct NDNBOOST_PP_CAT(apply_wrap,i_)<AUX778076_APPLY_WRAP_SPEC_PARAMS(i_, int)> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 168 | { |
| 169 | typedef int type; |
| 170 | }; |
| 171 | #endif |
| 172 | |
| 173 | # undef i_ |
| 174 | |
| 175 | ///// iteration, depth == 2 |
| 176 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 177 | #elif NDNBOOST_PP_ITERATION_DEPTH() == 2 |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 178 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 179 | # define j_ NDNBOOST_PP_FRAME_ITERATION(2) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 180 | |
| 181 | #if i_ == 0 && j_ == 0 \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 182 | && defined(NDNBOOST_MPL_CFG_BCC590_WORKAROUNDS) \ |
| 183 | && !defined(NDNBOOST_MPL_CFG_NO_HAS_APPLY) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 184 | |
| 185 | template< typename F, bool F_has_apply > |
| 186 | struct apply_wrap_impl0_bcb { |
| 187 | typedef typename F::template apply< na > type; |
| 188 | }; |
| 189 | |
| 190 | template< typename F > |
| 191 | struct apply_wrap_impl0_bcb< F, true > { |
| 192 | typedef typename F::apply type; |
| 193 | }; |
| 194 | |
| 195 | template< |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 196 | typename F NDNBOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 197 | > |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 198 | struct NDNBOOST_PP_CAT(apply_wrap_impl,i_)< |
| 199 | NDNBOOST_MPL_PP_ADD(i_, j_) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 200 | , F |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 201 | NDNBOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, T) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 202 | > |
| 203 | { |
| 204 | typedef apply_wrap_impl0_bcb< F, aux::has_apply< F >::value >::type type; |
| 205 | }; |
| 206 | #else |
| 207 | |
| 208 | template< |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 209 | typename F NDNBOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 210 | > |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 211 | struct NDNBOOST_PP_CAT(apply_wrap_impl,i_)< |
| 212 | NDNBOOST_MPL_PP_ADD(i_, j_) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 213 | , F |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 214 | NDNBOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, T) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 215 | > |
| 216 | { |
| 217 | typedef typename F::template apply< |
| 218 | AUX778076_APPLY_WRAP_PARAMS(i_, T) |
| 219 | #if i_ == 0 && j_ == 0 |
| 220 | /// since the defaults are "lost", we have to pass *something* even for nullary |
| 221 | /// metafunction classes |
| 222 | na |
| 223 | #else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 224 | NDNBOOST_PP_COMMA_IF(NDNBOOST_PP_AND(i_, j_)) NDNBOOST_MPL_PP_ENUM(j_, na) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 225 | #endif |
| 226 | > type; |
| 227 | }; |
| 228 | |
| 229 | #endif |
| 230 | |
| 231 | # undef j_ |
| 232 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 233 | #endif // NDNBOOST_PP_ITERATION_DEPTH() |
| 234 | #endif // NDNBOOST_PP_IS_ITERATING |