Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 1 | |
| 2 | #if !defined(BOOST_PP_IS_ITERATING) |
| 3 | |
| 4 | ///// header body |
| 5 | |
| 6 | #ifndef BOOST_MPL_APPLY_WRAP_HPP_INCLUDED |
| 7 | #define BOOST_MPL_APPLY_WRAP_HPP_INCLUDED |
| 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 | |
| 21 | #if !defined(BOOST_MPL_PREPROCESSING_MODE) |
| 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 | |
| 30 | #if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \ |
| 31 | && !defined(BOOST_MPL_PREPROCESSING_MODE) |
| 32 | |
| 33 | # define BOOST_MPL_PREPROCESSED_HEADER apply_wrap.hpp |
| 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) \ |
| 59 | BOOST_MPL_PP_PARAMS(n, param) \ |
| 60 | /**/ |
| 61 | |
| 62 | # define AUX778076_APPLY_WRAP_SPEC_PARAMS(n, param) \ |
| 63 | BOOST_MPL_PP_ENUM(BOOST_PP_INC(n), param) \ |
| 64 | /**/ |
| 65 | |
| 66 | |
| 67 | #define BOOST_PP_ITERATION_PARAMS_1 \ |
| 68 | (3,(0, BOOST_MPL_LIMIT_METAFUNCTION_ARITY, <ndnboost/mpl/apply_wrap.hpp>)) |
| 69 | #include BOOST_PP_ITERATE() |
| 70 | |
| 71 | |
| 72 | # undef AUX778076_APPLY_WRAP_SPEC_PARAMS |
| 73 | # undef AUX778076_APPLY_WRAP_PARAMS |
| 74 | |
| 75 | }} |
| 76 | |
| 77 | #endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS |
| 78 | #endif // BOOST_MPL_APPLY_WRAP_HPP_INCLUDED |
| 79 | |
| 80 | ///// iteration, depth == 1 |
| 81 | |
| 82 | // For gcc 4.4 compatability, we must include the |
| 83 | // BOOST_PP_ITERATION_DEPTH test inside an #else clause. |
| 84 | #else // BOOST_PP_IS_ITERATING |
| 85 | #if BOOST_PP_ITERATION_DEPTH() == 1 |
| 86 | |
| 87 | # define i_ BOOST_PP_FRAME_ITERATION(1) |
| 88 | |
| 89 | # if BOOST_WORKAROUND(BOOST_MSVC, < 1300) |
| 90 | // MSVC version |
| 91 | |
| 92 | #define AUX778076_MSVC_DTW_NAME BOOST_PP_CAT(msvc_apply,i_) |
| 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< |
| 98 | typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T) |
| 99 | > |
| 100 | struct BOOST_PP_CAT(apply_wrap,i_) |
| 101 | { |
| 102 | // Metafunction forwarding confuses vc6 |
| 103 | typedef typename BOOST_PP_CAT(msvc_apply,i_)<F>::template result_< |
| 104 | AUX778076_APPLY_WRAP_PARAMS(i_, T) |
| 105 | >::type type; |
| 106 | }; |
| 107 | |
| 108 | # elif defined(BOOST_MPL_CFG_BROKEN_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES) |
| 109 | // MWCW/Borland version |
| 110 | |
| 111 | template< |
| 112 | int N, typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T) |
| 113 | > |
| 114 | struct BOOST_PP_CAT(apply_wrap_impl,i_); |
| 115 | |
| 116 | #define BOOST_PP_ITERATION_PARAMS_2 \ |
| 117 | (3,(0, BOOST_MPL_LIMIT_METAFUNCTION_ARITY - i_, <ndnboost/mpl/apply_wrap.hpp>)) |
| 118 | #include BOOST_PP_ITERATE() |
| 119 | |
| 120 | template< |
| 121 | typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T) |
| 122 | > |
| 123 | struct BOOST_PP_CAT(apply_wrap,i_) |
| 124 | : BOOST_PP_CAT(apply_wrap_impl,i_)< |
| 125 | ::ndnboost::mpl::aux::arity<F,i_>::value |
| 126 | , F |
| 127 | BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, T) |
| 128 | >::type |
| 129 | { |
| 130 | }; |
| 131 | |
| 132 | # else |
| 133 | // ISO98 C++, with minor concession to vc7 |
| 134 | |
| 135 | template< |
| 136 | typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T) |
| 137 | #if i_ == 0 |
| 138 | , typename has_apply_ = typename aux::has_apply<F>::type |
| 139 | #endif |
| 140 | > |
| 141 | struct BOOST_PP_CAT(apply_wrap,i_) |
| 142 | // metafunction forwarding confuses MSVC 7.0 |
| 143 | #if !BOOST_WORKAROUND(BOOST_MSVC, == 1300) |
| 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 | |
| 154 | #if i_ == 0 && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) |
| 155 | template< typename F > |
| 156 | struct BOOST_PP_CAT(apply_wrap,i_)<F,true_> |
| 157 | : F::apply |
| 158 | { |
| 159 | }; |
| 160 | #endif |
| 161 | |
| 162 | # endif // workarounds |
| 163 | |
| 164 | #if defined(BOOST_MPL_CFG_MSVC_ETI_BUG) |
| 165 | /// workaround for ETI bug |
| 166 | template<> |
| 167 | struct BOOST_PP_CAT(apply_wrap,i_)<AUX778076_APPLY_WRAP_SPEC_PARAMS(i_, int)> |
| 168 | { |
| 169 | typedef int type; |
| 170 | }; |
| 171 | #endif |
| 172 | |
| 173 | # undef i_ |
| 174 | |
| 175 | ///// iteration, depth == 2 |
| 176 | |
| 177 | #elif BOOST_PP_ITERATION_DEPTH() == 2 |
| 178 | |
| 179 | # define j_ BOOST_PP_FRAME_ITERATION(2) |
| 180 | |
| 181 | #if i_ == 0 && j_ == 0 \ |
| 182 | && defined(BOOST_MPL_CFG_BCC590_WORKAROUNDS) \ |
| 183 | && !defined(BOOST_MPL_CFG_NO_HAS_APPLY) |
| 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< |
| 196 | typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T) |
| 197 | > |
| 198 | struct BOOST_PP_CAT(apply_wrap_impl,i_)< |
| 199 | BOOST_MPL_PP_ADD(i_, j_) |
| 200 | , F |
| 201 | BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, T) |
| 202 | > |
| 203 | { |
| 204 | typedef apply_wrap_impl0_bcb< F, aux::has_apply< F >::value >::type type; |
| 205 | }; |
| 206 | #else |
| 207 | |
| 208 | template< |
| 209 | typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T) |
| 210 | > |
| 211 | struct BOOST_PP_CAT(apply_wrap_impl,i_)< |
| 212 | BOOST_MPL_PP_ADD(i_, j_) |
| 213 | , F |
| 214 | BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, T) |
| 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 |
| 224 | BOOST_PP_COMMA_IF(BOOST_PP_AND(i_, j_)) BOOST_MPL_PP_ENUM(j_, na) |
| 225 | #endif |
| 226 | > type; |
| 227 | }; |
| 228 | |
| 229 | #endif |
| 230 | |
| 231 | # undef j_ |
| 232 | |
| 233 | #endif // BOOST_PP_ITERATION_DEPTH() |
| 234 | #endif // BOOST_PP_IS_ITERATING |