]> git.lyx.org Git - lyx.git/blob - boost/boost/mpl/integral_c.hpp
complie fix
[lyx.git] / boost / boost / mpl / integral_c.hpp
1 //-----------------------------------------------------------------------------
2 // boost/mpl/intergal_c.hpp header file
3 // See http://www.boost.org for updates, documentation, and revision history.
4 //-----------------------------------------------------------------------------
5 //
6 // Copyright (c) 2000-02
7 // Aleksey Gurtovoy
8 //
9 // Permission to use, copy, modify, distribute and sell this software
10 // and its documentation for any purpose is hereby granted without fee, 
11 // provided that the above copyright notice appears in all copies and 
12 // that both the copyright notice and this permission notice appear in 
13 // supporting documentation. No representations are made about the 
14 // suitability of this software for any purpose. It is provided "as is" 
15 // without express or implied warranty.
16
17 #ifndef BOOST_MPL_INTEGRAL_C_HPP_INCLUDED
18 #define BOOST_MPL_INTEGRAL_C_HPP_INCLUDED
19
20 #include "boost/config.hpp"
21
22 namespace boost {
23 namespace mpl {
24
25 template< typename T, T N >
26 struct integral_c
27 {
28     BOOST_STATIC_CONSTANT(T, value = N);
29     typedef integral_c type;
30     typedef T value_type;
31
32     // have to #ifdef here: some compilers don't like the 'N + 1' form (MSVC),
33     // while some other don't like 'value + 1' (Borland), and some don't like
34     // either
35 #if defined(__EDG_VERSION__) && __EDG_VERSION__ <= 243
36  private:
37     BOOST_STATIC_CONSTANT(T, next_value = (N + 1));
38     BOOST_STATIC_CONSTANT(T, prior_value = (N - 1));
39  public:
40     typedef integral_c<T, next_value> next;
41     typedef integral_c<T, prior_value> prior;
42 #elif defined(__BORLANDC__) && (__BORLANDC__ <= 0x561 || !defined(BOOST_STRICT_CONFIG)) \
43    || defined(__IBMCPP__) && (__IBMCPP__ <= 502 || !defined(BOOST_STRICT_CONFIG))
44     typedef integral_c<T, (N + 1)> next;
45     typedef integral_c<T, (N - 1)> prior;
46 #else
47     typedef integral_c<T, (value + 1)> next;
48     typedef integral_c<T, (value - 1)> prior;
49 #endif
50
51     // enables uniform function call syntax for families of overloaded 
52     // functions that return objects of both arithmetic ('int', 'long',
53     // 'double', etc.) and 'integral_c<..>' types (for an example, see 
54     // "mpl/example/power.cpp")
55     operator T() const { return this->value; } 
56 };
57
58 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
59  && !defined(__BORLANDC__) || __BORLANDC__ > 0x551
60 // 'bool' constant doesn't have 'next'/'prior' members
61 template< bool C >
62 struct integral_c<bool, C>
63 {
64     BOOST_STATIC_CONSTANT(bool, value = C);
65     typedef integral_c type;
66     operator bool() const { return this->value; }
67 };
68 #endif
69
70 } // namespace mpl
71 } // namespace boost 
72
73 #endif // BOOST_MPL_INTEGRAL_C_HPP_INCLUDED