blob: 462834ae6b73f24a147709041ff61f3daf24ce28 [file] [log] [blame]
Jeff Thompsonf7d49942013-08-01 16:47:40 -07001
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 Thompson2277ce52013-08-01 17:34:11 -070016#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 Thompsonf7d49942013-08-01 16:47:40 -070021
Jeff Thompson2277ce52013-08-01 17:34:11 -070022#include <ndnboost/preprocessor/cat.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070023
24#if !defined(AUX_WRAPPER_NAME)
Jeff Thompson3d613fd2013-10-15 15:39:04 -070025# define AUX_WRAPPER_NAME NDNBOOST_PP_CAT(AUX_WRAPPER_VALUE_TYPE,_)
Jeff Thompsonf7d49942013-08-01 16:47:40 -070026#endif
27
28#if !defined(AUX_WRAPPER_PARAMS)
Jeff Thompson3d613fd2013-10-15 15:39:04 -070029# define AUX_WRAPPER_PARAMS(N) NDNBOOST_MPL_AUX_NTTP_DECL(AUX_WRAPPER_VALUE_TYPE, N)
Jeff Thompsonf7d49942013-08-01 16:47:40 -070030#endif
31
32#if !defined(AUX_WRAPPER_INST)
Jeff Thompson3d613fd2013-10-15 15:39:04 -070033# if NDNBOOST_WORKAROUND(__MWERKS__, <= 0x2407)
Jeff Thompsonf7d49942013-08-01 16:47:40 -070034# define AUX_WRAPPER_INST(value) AUX_WRAPPER_NAME< value >
35# else
Jeff Thompson3d613fd2013-10-15 15:39:04 -070036# define AUX_WRAPPER_INST(value) NDNBOOST_MPL_AUX_ADL_BARRIER_NAMESPACE::AUX_WRAPPER_NAME< value >
Jeff Thompsonf7d49942013-08-01 16:47:40 -070037# endif
38#endif
39
Jeff Thompson3d613fd2013-10-15 15:39:04 -070040NDNBOOST_MPL_AUX_ADL_BARRIER_NAMESPACE_OPEN
Jeff Thompsonf7d49942013-08-01 16:47:40 -070041
42template< AUX_WRAPPER_PARAMS(N) >
43struct AUX_WRAPPER_NAME
44{
Jeff Thompson3d613fd2013-10-15 15:39:04 -070045 NDNBOOST_STATIC_CONSTANT(AUX_WRAPPER_VALUE_TYPE, value = N);
Jeff Thompsonf7d49942013-08-01 16:47:40 -070046// 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 Thompson3d613fd2013-10-15 15:39:04 -070048#if NDNBOOST_WORKAROUND(__EDG_VERSION__, <= 238)
Jeff Thompsonf7d49942013-08-01 16:47:40 -070049 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 Thompson3d613fd2013-10-15 15:39:04 -070059#if NDNBOOST_WORKAROUND(__EDG_VERSION__, <= 243)
Jeff Thompsonf7d49942013-08-01 16:47:40 -070060 private:
Jeff Thompson3d613fd2013-10-15 15:39:04 -070061 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 Thompsonf7d49942013-08-01 16:47:40 -070063 public:
64 typedef AUX_WRAPPER_INST(next_value) next;
65 typedef AUX_WRAPPER_INST(prior_value) prior;
Jeff Thompson3d613fd2013-10-15 15:39:04 -070066#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 Thompsonf7d49942013-08-01 16:47:40 -070071#else
Jeff Thompson3d613fd2013-10-15 15:39:04 -070072 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 Thompsonf7d49942013-08-01 16:47:40 -070074#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 Thompson3d613fd2013-10-15 15:39:04 -070083#if !defined(NDNBOOST_NO_INCLASS_MEMBER_INITIALIZATION)
Jeff Thompsonf7d49942013-08-01 16:47:40 -070084template< AUX_WRAPPER_PARAMS(N) >
85AUX_WRAPPER_VALUE_TYPE const AUX_WRAPPER_INST(N)::value;
86#endif
87
Jeff Thompson3d613fd2013-10-15 15:39:04 -070088NDNBOOST_MPL_AUX_ADL_BARRIER_NAMESPACE_CLOSE
Jeff Thompsonf7d49942013-08-01 16:47:40 -070089
90#undef AUX_WRAPPER_NAME
91#undef AUX_WRAPPER_PARAMS
92#undef AUX_WRAPPER_INST
93#undef AUX_WRAPPER_VALUE_TYPE