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 | // NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION! |
| 7 | |
| 8 | // Copyright Aleksey Gurtovoy 2000-2004 |
| 9 | // |
| 10 | // Distributed under the Boost Software License, Version 1.0. |
| 11 | // (See accompanying file LICENSE_1_0.txt or copy at |
| 12 | // http://www.boost.org/LICENSE_1_0.txt) |
| 13 | // |
| 14 | // See http://www.boost.org/libs/mpl for documentation. |
| 15 | |
| 16 | // $Id: numeric_op.hpp 49267 2008-10-11 06:19:02Z agurtovoy $ |
| 17 | // $Date: 2008-10-10 23:19:02 -0700 (Fri, 10 Oct 2008) $ |
| 18 | // $Revision: 49267 $ |
| 19 | |
| 20 | #if !defined(BOOST_MPL_PREPROCESSING_MODE) |
| 21 | # include <ndnboost/mpl/numeric_cast.hpp> |
| 22 | # include <ndnboost/mpl/apply_wrap.hpp> |
| 23 | # include <ndnboost/mpl/if.hpp> |
| 24 | # include <ndnboost/mpl/tag.hpp> |
| 25 | # include <ndnboost/mpl/aux_/numeric_cast_utils.hpp> |
| 26 | # include <ndnboost/mpl/aux_/na.hpp> |
| 27 | # include <ndnboost/mpl/aux_/na_spec.hpp> |
| 28 | # include <ndnboost/mpl/aux_/lambda_support.hpp> |
| 29 | # include <ndnboost/mpl/aux_/msvc_eti_base.hpp> |
| 30 | # include <ndnboost/mpl/aux_/value_wknd.hpp> |
| 31 | # include <ndnboost/mpl/aux_/config/eti.hpp> |
| 32 | # include <ndnboost/mpl/aux_/nttp_decl.hpp> |
| 33 | #endif |
| 34 | |
| 35 | #include <ndnboost/mpl/aux_/config/static_constant.hpp> |
| 36 | |
| 37 | #if defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \ |
| 38 | || defined(BOOST_MPL_PREPROCESSING_MODE) |
| 39 | |
| 40 | # include <ndnboost/mpl/limits/arity.hpp> |
| 41 | # include <ndnboost/mpl/aux_/preprocessor/partial_spec_params.hpp> |
| 42 | # include <ndnboost/mpl/aux_/preprocessor/def_params_tail.hpp> |
| 43 | # include <ndnboost/mpl/aux_/preprocessor/repeat.hpp> |
| 44 | # include <ndnboost/mpl/aux_/preprocessor/ext_params.hpp> |
| 45 | # include <ndnboost/mpl/aux_/preprocessor/params.hpp> |
| 46 | # include <ndnboost/mpl/aux_/preprocessor/enum.hpp> |
| 47 | # include <ndnboost/mpl/aux_/preprocessor/add.hpp> |
| 48 | # include <ndnboost/mpl/aux_/preprocessor/sub.hpp> |
| 49 | # include <ndnboost/mpl/aux_/config/ctps.hpp> |
| 50 | # include <ndnboost/mpl/aux_/config/eti.hpp> |
| 51 | # include <ndnboost/mpl/aux_/config/msvc.hpp> |
| 52 | # include <ndnboost/mpl/aux_/config/workaround.hpp> |
| 53 | |
| 54 | # include <ndnboost/preprocessor/dec.hpp> |
| 55 | # include <ndnboost/preprocessor/inc.hpp> |
| 56 | # include <ndnboost/preprocessor/iterate.hpp> |
| 57 | # include <ndnboost/preprocessor/cat.hpp> |
| 58 | |
| 59 | |
| 60 | #if !defined(AUX778076_OP_ARITY) |
| 61 | # define AUX778076_OP_ARITY BOOST_MPL_LIMIT_METAFUNCTION_ARITY |
| 62 | #endif |
| 63 | |
| 64 | #if !defined(AUX778076_OP_IMPL_NAME) |
| 65 | # define AUX778076_OP_IMPL_NAME BOOST_PP_CAT(AUX778076_OP_PREFIX,_impl) |
| 66 | #endif |
| 67 | |
| 68 | #if !defined(AUX778076_OP_TAG_NAME) |
| 69 | # define AUX778076_OP_TAG_NAME BOOST_PP_CAT(AUX778076_OP_PREFIX,_tag) |
| 70 | #endif |
| 71 | |
| 72 | namespace ndnboost { namespace mpl { |
| 73 | |
| 74 | template< |
| 75 | typename Tag1 |
| 76 | , typename Tag2 |
| 77 | #if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) |
| 78 | , BOOST_MPL_AUX_NTTP_DECL(int, tag1_) = BOOST_MPL_AUX_MSVC_VALUE_WKND(Tag1)::value |
| 79 | , BOOST_MPL_AUX_NTTP_DECL(int, tag2_) = BOOST_MPL_AUX_MSVC_VALUE_WKND(Tag2)::value |
| 80 | > |
| 81 | struct AUX778076_OP_IMPL_NAME |
| 82 | : if_c< |
| 83 | ( tag1_ > tag2_ ) |
| 84 | #else |
| 85 | > |
| 86 | struct AUX778076_OP_IMPL_NAME |
| 87 | : if_c< |
| 88 | ( BOOST_MPL_AUX_NESTED_VALUE_WKND(int, Tag1) |
| 89 | > BOOST_MPL_AUX_NESTED_VALUE_WKND(int, Tag2) |
| 90 | ) |
| 91 | #endif |
| 92 | , aux::cast2nd_impl< AUX778076_OP_IMPL_NAME<Tag1,Tag1>,Tag1,Tag2 > |
| 93 | , aux::cast1st_impl< AUX778076_OP_IMPL_NAME<Tag2,Tag2>,Tag1,Tag2 > |
| 94 | >::type |
| 95 | { |
| 96 | }; |
| 97 | |
| 98 | /// for Digital Mars C++/compilers with no CTPS/TTP support |
| 99 | template<> struct AUX778076_OP_IMPL_NAME<na,na> |
| 100 | { |
| 101 | template< typename U1, typename U2 > struct apply |
| 102 | { |
| 103 | typedef apply type; |
| 104 | BOOST_STATIC_CONSTANT(int, value = 0); |
| 105 | }; |
| 106 | }; |
| 107 | |
| 108 | #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) |
| 109 | template< typename Tag > struct AUX778076_OP_IMPL_NAME<na,Tag> |
| 110 | { |
| 111 | template< typename U1, typename U2 > struct apply |
| 112 | { |
| 113 | typedef apply type; |
| 114 | BOOST_STATIC_CONSTANT(int, value = 0); |
| 115 | }; |
| 116 | }; |
| 117 | |
| 118 | template< typename Tag > struct AUX778076_OP_IMPL_NAME<Tag,na> |
| 119 | { |
| 120 | template< typename U1, typename U2 > struct apply |
| 121 | { |
| 122 | typedef apply type; |
| 123 | BOOST_STATIC_CONSTANT(int, value = 0); |
| 124 | }; |
| 125 | }; |
| 126 | #else |
| 127 | template<> struct AUX778076_OP_IMPL_NAME<na,integral_c_tag> |
| 128 | { |
| 129 | template< typename U1, typename U2 > struct apply |
| 130 | { |
| 131 | typedef apply type; |
| 132 | BOOST_STATIC_CONSTANT(int, value = 0); |
| 133 | }; |
| 134 | }; |
| 135 | |
| 136 | template<> struct AUX778076_OP_IMPL_NAME<integral_c_tag,na> |
| 137 | { |
| 138 | template< typename U1, typename U2 > struct apply |
| 139 | { |
| 140 | typedef apply type; |
| 141 | BOOST_STATIC_CONSTANT(int, value = 0); |
| 142 | }; |
| 143 | }; |
| 144 | #endif |
| 145 | |
| 146 | |
| 147 | #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ |
| 148 | && BOOST_WORKAROUND(BOOST_MSVC, >= 1300) |
| 149 | template< typename T > struct AUX778076_OP_TAG_NAME |
| 150 | : tag<T,na> |
| 151 | { |
| 152 | }; |
| 153 | #else |
| 154 | template< typename T > struct AUX778076_OP_TAG_NAME |
| 155 | { |
| 156 | typedef typename T::tag type; |
| 157 | }; |
| 158 | #endif |
| 159 | |
| 160 | |
| 161 | #if AUX778076_OP_ARITY != 2 |
| 162 | |
| 163 | # if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) |
| 164 | |
| 165 | # define AUX778076_OP_RIGHT_OPERAND(unused, i, N) , BOOST_PP_CAT(N, BOOST_MPL_PP_ADD(i, 2))> |
| 166 | # define AUX778076_OP_N_CALLS(i, N) \ |
| 167 | BOOST_MPL_PP_REPEAT( BOOST_PP_DEC(i), BOOST_MPL_PP_REPEAT_IDENTITY_FUNC, AUX778076_OP_NAME< ) \ |
| 168 | N1 BOOST_MPL_PP_REPEAT( BOOST_MPL_PP_SUB(i, 1), AUX778076_OP_RIGHT_OPERAND, N ) \ |
| 169 | /**/ |
| 170 | |
| 171 | template< |
| 172 | typename BOOST_MPL_AUX_NA_PARAM(N1) |
| 173 | , typename BOOST_MPL_AUX_NA_PARAM(N2) |
| 174 | BOOST_MPL_PP_DEF_PARAMS_TAIL(2, typename N, na) |
| 175 | > |
| 176 | struct AUX778076_OP_NAME |
| 177 | : AUX778076_OP_N_CALLS(AUX778076_OP_ARITY, N) |
| 178 | { |
| 179 | BOOST_MPL_AUX_LAMBDA_SUPPORT( |
| 180 | AUX778076_OP_ARITY |
| 181 | , AUX778076_OP_NAME |
| 182 | , ( BOOST_MPL_PP_PARAMS(AUX778076_OP_ARITY, N) ) |
| 183 | ) |
| 184 | }; |
| 185 | |
| 186 | #define BOOST_PP_ITERATION_PARAMS_1 \ |
| 187 | (3,( BOOST_PP_DEC(AUX778076_OP_ARITY), 2, <ndnboost/mpl/aux_/numeric_op.hpp> )) |
| 188 | #include BOOST_PP_ITERATE() |
| 189 | |
| 190 | # undef AUX778076_OP_N_CALLS |
| 191 | # undef AUX778076_OP_RIGHT_OPERAND |
| 192 | |
| 193 | # else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
| 194 | |
| 195 | /// forward declaration |
| 196 | template< |
| 197 | typename BOOST_MPL_AUX_NA_PARAM(N1) |
| 198 | , typename BOOST_MPL_AUX_NA_PARAM(N2) |
| 199 | > |
| 200 | struct BOOST_PP_CAT(AUX778076_OP_NAME,2); |
| 201 | |
| 202 | template< |
| 203 | typename BOOST_MPL_AUX_NA_PARAM(N1) |
| 204 | , typename BOOST_MPL_AUX_NA_PARAM(N2) |
| 205 | BOOST_MPL_PP_DEF_PARAMS_TAIL(2, typename N, na) |
| 206 | > |
| 207 | struct AUX778076_OP_NAME |
| 208 | #if BOOST_WORKAROUND(BOOST_MSVC, == 1300) |
| 209 | : aux::msvc_eti_base< typename if_< |
| 210 | #else |
| 211 | : if_< |
| 212 | #endif |
| 213 | is_na<N3> |
| 214 | , BOOST_PP_CAT(AUX778076_OP_NAME,2)<N1,N2> |
| 215 | , AUX778076_OP_NAME< |
| 216 | BOOST_PP_CAT(AUX778076_OP_NAME,2)<N1,N2> |
| 217 | , BOOST_MPL_PP_EXT_PARAMS(3, BOOST_PP_INC(AUX778076_OP_ARITY), N) |
| 218 | > |
| 219 | >::type |
| 220 | #if BOOST_WORKAROUND(BOOST_MSVC, == 1300) |
| 221 | > |
| 222 | #endif |
| 223 | { |
| 224 | BOOST_MPL_AUX_LAMBDA_SUPPORT( |
| 225 | AUX778076_OP_ARITY |
| 226 | , AUX778076_OP_NAME |
| 227 | , ( BOOST_MPL_PP_PARAMS(AUX778076_OP_ARITY, N) ) |
| 228 | ) |
| 229 | }; |
| 230 | |
| 231 | template< |
| 232 | typename N1 |
| 233 | , typename N2 |
| 234 | > |
| 235 | struct BOOST_PP_CAT(AUX778076_OP_NAME,2) |
| 236 | |
| 237 | #endif |
| 238 | |
| 239 | #else // AUX778076_OP_ARITY == 2 |
| 240 | |
| 241 | template< |
| 242 | typename BOOST_MPL_AUX_NA_PARAM(N1) |
| 243 | , typename BOOST_MPL_AUX_NA_PARAM(N2) |
| 244 | > |
| 245 | struct AUX778076_OP_NAME |
| 246 | |
| 247 | #endif |
| 248 | |
| 249 | #if !defined(BOOST_MPL_CFG_MSVC_ETI_BUG) |
| 250 | : AUX778076_OP_IMPL_NAME< |
| 251 | typename AUX778076_OP_TAG_NAME<N1>::type |
| 252 | , typename AUX778076_OP_TAG_NAME<N2>::type |
| 253 | >::template apply<N1,N2>::type |
| 254 | #else |
| 255 | : aux::msvc_eti_base< typename apply_wrap2< |
| 256 | AUX778076_OP_IMPL_NAME< |
| 257 | typename AUX778076_OP_TAG_NAME<N1>::type |
| 258 | , typename AUX778076_OP_TAG_NAME<N2>::type |
| 259 | > |
| 260 | , N1 |
| 261 | , N2 |
| 262 | >::type >::type |
| 263 | #endif |
| 264 | { |
| 265 | #if AUX778076_OP_ARITY != 2 |
| 266 | |
| 267 | # if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) |
| 268 | BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC( |
| 269 | AUX778076_OP_ARITY |
| 270 | , AUX778076_OP_NAME |
| 271 | , ( BOOST_MPL_PP_PARTIAL_SPEC_PARAMS(2, N, na) ) |
| 272 | ) |
| 273 | # else |
| 274 | BOOST_MPL_AUX_LAMBDA_SUPPORT(2, BOOST_PP_CAT(AUX778076_OP_NAME,2), (N1, N2)) |
| 275 | # endif |
| 276 | |
| 277 | #else |
| 278 | BOOST_MPL_AUX_LAMBDA_SUPPORT(2, AUX778076_OP_NAME, (N1, N2)) |
| 279 | #endif |
| 280 | }; |
| 281 | |
| 282 | BOOST_MPL_AUX_NA_SPEC2(2, AUX778076_OP_ARITY, AUX778076_OP_NAME) |
| 283 | |
| 284 | }} |
| 285 | |
| 286 | #endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS |
| 287 | |
| 288 | ///// iteration, depth == 1 |
| 289 | |
| 290 | // For gcc 4.4 compatability, we must include the |
| 291 | // BOOST_PP_ITERATION_DEPTH test inside an #else clause. |
| 292 | #else // BOOST_PP_IS_ITERATING |
| 293 | #if BOOST_PP_ITERATION_DEPTH() == 1 |
| 294 | |
| 295 | # define i_ BOOST_PP_FRAME_ITERATION(1) |
| 296 | |
| 297 | template< |
| 298 | BOOST_MPL_PP_PARAMS(i_, typename N) |
| 299 | > |
| 300 | struct AUX778076_OP_NAME<BOOST_MPL_PP_PARTIAL_SPEC_PARAMS(i_, N, na)> |
| 301 | #if i_ != 2 |
| 302 | : AUX778076_OP_N_CALLS(i_, N) |
| 303 | { |
| 304 | BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC( |
| 305 | AUX778076_OP_ARITY |
| 306 | , AUX778076_OP_NAME |
| 307 | , ( BOOST_MPL_PP_PARTIAL_SPEC_PARAMS(i_, N, na) ) |
| 308 | ) |
| 309 | }; |
| 310 | #endif |
| 311 | |
| 312 | # undef i_ |
| 313 | |
| 314 | #endif // BOOST_PP_ITERATION_DEPTH() |
| 315 | #endif // BOOST_PP_IS_ITERATING |