Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 1 | |
| 2 | // Copyright Aleksey Gurtovoy 2000-2006 |
| 3 | // |
| 4 | // Distributed under the Boost Software License, Version 1.0. |
| 5 | // (See accompanying file LICENSE_1_0.txt or copy at |
| 6 | // http://www.boost.org/LICENSE_1_0.txt) |
| 7 | // |
| 8 | // See http://www.boost.org/libs/mpl for documentation. |
| 9 | |
| 10 | // $Id: integral_wrapper.hpp 49267 2008-10-11 06:19:02Z agurtovoy $ |
| 11 | // $Date: 2008-10-10 23:19:02 -0700 (Fri, 10 Oct 2008) $ |
| 12 | // $Revision: 49267 $ |
| 13 | |
| 14 | // NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION! |
| 15 | |
Jeff Thompson | 2277ce5 | 2013-08-01 17:34:11 -0700 | [diff] [blame] | 16 | #include <ndnboost/mpl/integral_c_tag.hpp> |
| 17 | #include <ndnboost/mpl/aux_/static_cast.hpp> |
| 18 | #include <ndnboost/mpl/aux_/nttp_decl.hpp> |
| 19 | #include <ndnboost/mpl/aux_/config/static_constant.hpp> |
| 20 | #include <ndnboost/mpl/aux_/config/workaround.hpp> |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 21 | |
Jeff Thompson | 2277ce5 | 2013-08-01 17:34:11 -0700 | [diff] [blame] | 22 | #include <ndnboost/preprocessor/cat.hpp> |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 23 | |
| 24 | #if !defined(AUX_WRAPPER_NAME) |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 25 | # define AUX_WRAPPER_NAME NDNBOOST_PP_CAT(AUX_WRAPPER_VALUE_TYPE,_) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 26 | #endif |
| 27 | |
| 28 | #if !defined(AUX_WRAPPER_PARAMS) |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 29 | # define AUX_WRAPPER_PARAMS(N) NDNBOOST_MPL_AUX_NTTP_DECL(AUX_WRAPPER_VALUE_TYPE, N) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 30 | #endif |
| 31 | |
| 32 | #if !defined(AUX_WRAPPER_INST) |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 33 | # if NDNBOOST_WORKAROUND(__MWERKS__, <= 0x2407) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 34 | # define AUX_WRAPPER_INST(value) AUX_WRAPPER_NAME< value > |
| 35 | # else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 36 | # define AUX_WRAPPER_INST(value) NDNBOOST_MPL_AUX_ADL_BARRIER_NAMESPACE::AUX_WRAPPER_NAME< value > |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 37 | # endif |
| 38 | #endif |
| 39 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 40 | NDNBOOST_MPL_AUX_ADL_BARRIER_NAMESPACE_OPEN |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 41 | |
| 42 | template< AUX_WRAPPER_PARAMS(N) > |
| 43 | struct AUX_WRAPPER_NAME |
| 44 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 45 | NDNBOOST_STATIC_CONSTANT(AUX_WRAPPER_VALUE_TYPE, value = N); |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 46 | // agurt, 08/mar/03: SGI MIPSpro C++ workaround, have to #ifdef because some |
| 47 | // other compilers (e.g. MSVC) are not particulary happy about it |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 48 | #if NDNBOOST_WORKAROUND(__EDG_VERSION__, <= 238) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 49 | typedef struct AUX_WRAPPER_NAME type; |
| 50 | #else |
| 51 | typedef AUX_WRAPPER_NAME type; |
| 52 | #endif |
| 53 | typedef AUX_WRAPPER_VALUE_TYPE value_type; |
| 54 | typedef integral_c_tag tag; |
| 55 | |
| 56 | // have to #ifdef here: some compilers don't like the 'N + 1' form (MSVC), |
| 57 | // while some other don't like 'value + 1' (Borland), and some don't like |
| 58 | // either |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 59 | #if NDNBOOST_WORKAROUND(__EDG_VERSION__, <= 243) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 60 | private: |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 61 | NDNBOOST_STATIC_CONSTANT(AUX_WRAPPER_VALUE_TYPE, next_value = NDNBOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (N + 1))); |
| 62 | NDNBOOST_STATIC_CONSTANT(AUX_WRAPPER_VALUE_TYPE, prior_value = NDNBOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (N - 1))); |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 63 | public: |
| 64 | typedef AUX_WRAPPER_INST(next_value) next; |
| 65 | typedef AUX_WRAPPER_INST(prior_value) prior; |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 66 | #elif NDNBOOST_WORKAROUND(__BORLANDC__, NDNBOOST_TESTED_AT(0x561)) \ |
| 67 | || NDNBOOST_WORKAROUND(__IBMCPP__, NDNBOOST_TESTED_AT(502)) \ |
| 68 | || (NDNBOOST_WORKAROUND(__HP_aCC, <= 53800) && (NDNBOOST_WORKAROUND(__hpxstd98, != 1))) |
| 69 | typedef AUX_WRAPPER_INST( NDNBOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (N + 1)) ) next; |
| 70 | typedef AUX_WRAPPER_INST( NDNBOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (N - 1)) ) prior; |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 71 | #else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 72 | typedef AUX_WRAPPER_INST( NDNBOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (value + 1)) ) next; |
| 73 | typedef AUX_WRAPPER_INST( NDNBOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (value - 1)) ) prior; |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 74 | #endif |
| 75 | |
| 76 | // enables uniform function call syntax for families of overloaded |
| 77 | // functions that return objects of both arithmetic ('int', 'long', |
| 78 | // 'double', etc.) and wrapped integral types (for an example, see |
| 79 | // "mpl/example/power.cpp") |
| 80 | operator AUX_WRAPPER_VALUE_TYPE() const { return static_cast<AUX_WRAPPER_VALUE_TYPE>(this->value); } |
| 81 | }; |
| 82 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 83 | #if !defined(NDNBOOST_NO_INCLASS_MEMBER_INITIALIZATION) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 84 | template< AUX_WRAPPER_PARAMS(N) > |
| 85 | AUX_WRAPPER_VALUE_TYPE const AUX_WRAPPER_INST(N)::value; |
| 86 | #endif |
| 87 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 88 | NDNBOOST_MPL_AUX_ADL_BARRIER_NAMESPACE_CLOSE |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 89 | |
| 90 | #undef AUX_WRAPPER_NAME |
| 91 | #undef AUX_WRAPPER_PARAMS |
| 92 | #undef AUX_WRAPPER_INST |
| 93 | #undef AUX_WRAPPER_VALUE_TYPE |