1 //-----------------------------------------------------------------------------
2 // boost/mpl/intergal_c.hpp header file
3 // See http://www.boost.org for updates, documentation, and revision history.
4 //-----------------------------------------------------------------------------
6 // Copyright (c) 2000-02
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.
17 #ifndef BOOST_MPL_INTEGRAL_C_HPP_INCLUDED
18 #define BOOST_MPL_INTEGRAL_C_HPP_INCLUDED
20 #include "boost/config.hpp"
25 template< typename T, T N >
28 BOOST_STATIC_CONSTANT(T, value = N);
29 typedef integral_c type;
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
35 #if defined(__EDG_VERSION__) && __EDG_VERSION__ <= 243
37 BOOST_STATIC_CONSTANT(T, next_value = (N + 1));
38 BOOST_STATIC_CONSTANT(T, prior_value = (N - 1));
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;
47 typedef integral_c<T, (value + 1)> next;
48 typedef integral_c<T, (value - 1)> prior;
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; }
58 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
59 && !defined(__BORLANDC__) || __BORLANDC__ > 0x551
60 // 'bool' constant doesn't have 'next'/'prior' members
62 struct integral_c<bool, C>
64 BOOST_STATIC_CONSTANT(bool, value = C);
65 typedef integral_c type;
66 operator bool() const { return this->value; }
73 #endif // BOOST_MPL_INTEGRAL_C_HPP_INCLUDED