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