Files
boost_mpl/include/boost/mpl/aux_/integral_wrapper.hpp
T

96 lines
3.6 KiB
C++
Raw Normal View History

2003-02-25 23:11:41 +00:00
// + file: boost/mpl/aux_/intergal_wrapper.hpp
2003-04-12 18:25:44 +00:00
// + last modified: 12/apr/03
2003-02-25 23:11:41 +00:00
// Copyright (c) 2000-03
// Aleksey Gurtovoy
//
// Permission to use, copy, modify, distribute and sell this software
// and its documentation for any purpose is hereby granted without fee,
// provided that the above copyright notice appears in all copies and
// that both the copyright notice and this permission notice appear in
// supporting documentation. No representations are made about the
// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
//
// See http://www.boost.org/libs/mpl for documentation.
// no include guards, the header is intended for multiple inclusion!
2003-05-03 02:07:24 +00:00
#include "boost/mpl/aux_/static_cast.hpp"
2003-02-25 23:11:41 +00:00
#include "boost/mpl/aux_/config/nttp.hpp"
#include "boost/mpl/aux_/config/static_constant.hpp"
#include "boost/mpl/aux_/config/workaround.hpp"
#include "boost/preprocessor/cat.hpp"
#if !defined(AUX_WRAPPER_NAME)
# define AUX_WRAPPER_NAME BOOST_PP_CAT(AUX_WRAPPER_VALUE_TYPE,_)
2003-03-09 23:42:58 +00:00
#endif
#if !defined(AUX_WRAPPER_PARAMS)
2003-02-25 23:11:41 +00:00
# define AUX_WRAPPER_PARAMS(N) BOOST_MPL_AUX_NTTP_DECL(AUX_WRAPPER_VALUE_TYPE, N)
2003-03-09 23:42:58 +00:00
#endif
#if !defined(AUX_WRAPPER_INST)
2003-04-26 14:59:30 +00:00
# if BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
# define AUX_WRAPPER_INST(value) AUX_WRAPPER_NAME< value >
# else
# define AUX_WRAPPER_INST(value) mpl::AUX_WRAPPER_NAME< value >
# endif
2003-02-25 23:11:41 +00:00
#endif
namespace boost { namespace mpl {
template< AUX_WRAPPER_PARAMS(N) >
struct AUX_WRAPPER_NAME
{
BOOST_STATIC_CONSTANT(AUX_WRAPPER_VALUE_TYPE, value = N);
2003-03-09 03:51:32 +00:00
// agurt, 08/mar/03: SGI MIPSpro C++ workaround, have to #ifdef because some
// other compilers (e.g. MSVC) are not particulary happy about it
#if BOOST_WORKAROUND(__EDG_VERSION__, <= 238)
2003-03-08 00:25:47 +00:00
typedef struct AUX_WRAPPER_NAME type;
2003-03-09 03:51:32 +00:00
#else
typedef AUX_WRAPPER_NAME type;
#endif
2003-02-25 23:11:41 +00:00
typedef AUX_WRAPPER_VALUE_TYPE value_type;
2003-03-09 03:51:32 +00:00
// have to #ifdef here: some compilers don't like the 'N + 1' form (MSVC),
// while some other don't like 'value + 1' (Borland), and some don't like
// either
2003-02-25 23:11:41 +00:00
#if BOOST_WORKAROUND(__EDG_VERSION__, <= 243)
private:
2003-05-03 02:07:24 +00:00
BOOST_STATIC_CONSTANT(AUX_WRAPPER_VALUE_TYPE, next_value = BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (N + 1)));
BOOST_STATIC_CONSTANT(AUX_WRAPPER_VALUE_TYPE, prior_value = BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (N - 1)));
2003-02-25 23:11:41 +00:00
public:
typedef AUX_WRAPPER_INST(next_value) next;
typedef AUX_WRAPPER_INST(prior_value) prior;
#elif BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x561)) \
|| BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(502)) \
|| BOOST_WORKAROUND(__HP_aCC, BOOST_TESTED_AT(53800))
2003-05-03 02:07:24 +00:00
typedef AUX_WRAPPER_INST( BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (N + 1)) ) next;
typedef AUX_WRAPPER_INST( BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (N - 1)) ) prior;
2003-02-25 23:11:41 +00:00
#else
2003-05-03 02:07:24 +00:00
typedef AUX_WRAPPER_INST( BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (value + 1)) ) next;
typedef AUX_WRAPPER_INST( BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (value - 1)) ) prior;
2003-02-25 23:11:41 +00:00
#endif
// enables uniform function call syntax for families of overloaded
// functions that return objects of both arithmetic ('int', 'long',
// 'double', etc.) and wrapped integral types (for an example, see
// "mpl/example/power.cpp")
operator AUX_WRAPPER_VALUE_TYPE() const { return static_cast<AUX_WRAPPER_VALUE_TYPE>(this->value); }
2003-02-25 23:11:41 +00:00
};
2003-04-12 18:25:44 +00:00
#if !defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION)
template< AUX_WRAPPER_PARAMS(N) >
AUX_WRAPPER_VALUE_TYPE const AUX_WRAPPER_INST(N)::value;
#endif
2003-02-25 23:11:41 +00:00
}} // namespace boost::mpl
#undef AUX_WRAPPER_NAME
#undef AUX_WRAPPER_PARAMS
#undef AUX_WRAPPER_INST
#undef AUX_WRAPPER_VALUE_TYPE