]> git.lyx.org Git - lyx.git/blob - boost/boost/mpl/aux_/integral_wrapper.hpp
64ec3080c87f16858588388c7ac0e5c1a081293c
[lyx.git] / boost / boost / mpl / aux_ / integral_wrapper.hpp
1
2 // + file: boost/mpl/aux_/intergal_wrapper.hpp
3 // + last modified: 12/apr/03
4
5 // Copyright (c) 2000-03
6 // Aleksey Gurtovoy
7 //
8 // Permission to use, copy, modify, distribute and sell this software
9 // and its documentation for any purpose is hereby granted without fee, 
10 // provided that the above copyright notice appears in all copies and 
11 // that both the copyright notice and this permission notice appear in 
12 // supporting documentation. No representations are made about the 
13 // suitability of this software for any purpose. It is provided "as is" 
14 // without express or implied warranty.
15 //
16 // See http://www.boost.org/libs/mpl for documentation.
17
18 // no include guards, the header is intended for multiple inclusion!
19
20 #include "boost/mpl/aux_/static_cast.hpp"
21 #include "boost/mpl/aux_/config/nttp.hpp"
22 #include "boost/mpl/aux_/config/static_constant.hpp"
23 #include "boost/mpl/aux_/config/workaround.hpp"
24
25 #include "boost/preprocessor/cat.hpp"
26
27 #if !defined(AUX_WRAPPER_NAME)
28 #   define AUX_WRAPPER_NAME BOOST_PP_CAT(AUX_WRAPPER_VALUE_TYPE,_)
29 #endif
30
31 #if !defined(AUX_WRAPPER_PARAMS)
32 #   define AUX_WRAPPER_PARAMS(N) BOOST_MPL_AUX_NTTP_DECL(AUX_WRAPPER_VALUE_TYPE, N)
33 #endif
34
35 #if !defined(AUX_WRAPPER_INST)
36 #   if BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
37 #       define AUX_WRAPPER_INST(value) AUX_WRAPPER_NAME< value >
38 #   else 
39 #       define AUX_WRAPPER_INST(value) mpl::AUX_WRAPPER_NAME< value >
40 #   endif
41 #endif
42
43 namespace boost { namespace mpl {
44
45 template< AUX_WRAPPER_PARAMS(N) >
46 struct AUX_WRAPPER_NAME
47 {
48     BOOST_STATIC_CONSTANT(AUX_WRAPPER_VALUE_TYPE, value = N);
49 // agurt, 08/mar/03: SGI MIPSpro C++ workaround, have to #ifdef because some 
50 // other compilers (e.g. MSVC) are not particulary happy about it
51 #if BOOST_WORKAROUND(__EDG_VERSION__, <= 238)
52     typedef struct AUX_WRAPPER_NAME type;
53 #else
54     typedef AUX_WRAPPER_NAME type;
55 #endif
56     typedef AUX_WRAPPER_VALUE_TYPE value_type;
57
58 // have to #ifdef here: some compilers don't like the 'N + 1' form (MSVC),
59 // while some other don't like 'value + 1' (Borland), and some don't like
60 // either
61 #if BOOST_WORKAROUND(__EDG_VERSION__, <= 243)
62  private:
63     BOOST_STATIC_CONSTANT(AUX_WRAPPER_VALUE_TYPE, next_value = BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (N + 1)));
64     BOOST_STATIC_CONSTANT(AUX_WRAPPER_VALUE_TYPE, prior_value = BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (N - 1)));
65  public:
66     typedef AUX_WRAPPER_INST(next_value) next;
67     typedef AUX_WRAPPER_INST(prior_value) prior;
68 #elif BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x561)) \
69     || BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(502)) \
70     || BOOST_WORKAROUND(__HP_aCC, BOOST_TESTED_AT(53800))
71     typedef AUX_WRAPPER_INST( BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (N + 1)) ) next;
72     typedef AUX_WRAPPER_INST( BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (N - 1)) ) prior;
73 #else
74     typedef AUX_WRAPPER_INST( BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (value + 1)) ) next;
75     typedef AUX_WRAPPER_INST( BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (value - 1)) ) prior;
76 #endif
77
78     // enables uniform function call syntax for families of overloaded 
79     // functions that return objects of both arithmetic ('int', 'long',
80     // 'double', etc.) and wrapped integral types (for an example, see 
81     // "mpl/example/power.cpp")
82     operator AUX_WRAPPER_VALUE_TYPE() const { return static_cast<AUX_WRAPPER_VALUE_TYPE>(this->value); } 
83 };
84
85 #if !defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION)
86 template< AUX_WRAPPER_PARAMS(N) >
87 AUX_WRAPPER_VALUE_TYPE const AUX_WRAPPER_INST(N)::value;
88 #endif
89
90 }} // namespace boost::mpl
91
92 #undef AUX_WRAPPER_NAME
93 #undef AUX_WRAPPER_PARAMS
94 #undef AUX_WRAPPER_INST
95 #undef AUX_WRAPPER_VALUE_TYPE