arithmetic_op.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION
  2. // Copyright Aleksey Gurtovoy 2000-2004
  3. //
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. //
  8. // See http://www.boost.org/libs/mpl for documentation.
  9. // $Id$
  10. // $Date$
  11. // $Revision$
  12. #if !defined(BOOST_MPL_PREPROCESSING_MODE)
  13. # include <boost/mpl/integral_c.hpp>
  14. # include <boost/mpl/aux_/largest_int.hpp>
  15. # include <boost/mpl/aux_/value_wknd.hpp>
  16. #endif
  17. #if !defined(AUX778076_OP_PREFIX)
  18. # define AUX778076_OP_PREFIX AUX778076_OP_NAME
  19. #endif
  20. #include <boost/mpl/aux_/numeric_op.hpp>
  21. #include <boost/mpl/aux_/config/static_constant.hpp>
  22. #include <boost/mpl/aux_/config/use_preprocessed.hpp>
  23. #if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
  24. && !defined(BOOST_MPL_PREPROCESSING_MODE)
  25. # define BOOST_MPL_PREPROCESSED_HEADER AUX778076_OP_PREFIX.hpp
  26. # include <boost/mpl/aux_/include_preprocessed.hpp>
  27. #else
  28. # include <boost/mpl/aux_/config/workaround.hpp>
  29. # include <boost/preprocessor/cat.hpp>
  30. namespace boost { namespace mpl {
  31. #if defined(BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC)
  32. namespace aux {
  33. template< typename T, T n1, T n2 >
  34. struct BOOST_PP_CAT(AUX778076_OP_PREFIX,_wknd)
  35. {
  36. BOOST_STATIC_CONSTANT(T, value = (n1 AUX778076_OP_TOKEN n2));
  37. typedef integral_c<T,value> type;
  38. };
  39. }
  40. #endif
  41. template<>
  42. struct AUX778076_OP_IMPL_NAME<integral_c_tag,integral_c_tag>
  43. {
  44. template< typename N1, typename N2 > struct apply
  45. #if !defined(BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC)
  46. : integral_c<
  47. typename aux::largest_int<
  48. typename N1::value_type
  49. , typename N2::value_type
  50. >::type
  51. , ( BOOST_MPL_AUX_VALUE_WKND(N1)::value
  52. AUX778076_OP_TOKEN BOOST_MPL_AUX_VALUE_WKND(N2)::value
  53. )
  54. >
  55. #else
  56. : aux::BOOST_PP_CAT(AUX778076_OP_PREFIX,_wknd)<
  57. typename aux::largest_int<
  58. typename N1::value_type
  59. , typename N2::value_type
  60. >::type
  61. , N1::value
  62. , N2::value
  63. >::type
  64. #endif
  65. {
  66. };
  67. };
  68. }}
  69. #endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
  70. #undef AUX778076_OP_TAG_NAME
  71. #undef AUX778076_OP_IMPL_NAME
  72. #undef AUX778076_OP_ARITY
  73. #undef AUX778076_OP_PREFIX
  74. #undef AUX778076_OP_NAME
  75. #undef AUX778076_OP_TOKEN