numeric_cast_traits.hpp 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. //
  2. //! Copyright (c) 2011-2012
  3. //! Brandon Kohn
  4. //
  5. // Distributed under the Boost Software License, Version 1.0. (See
  6. // accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. #if !defined(BOOST_NUMERIC_CONVERSION_DONT_USE_PREPROCESSED_FILES)
  10. #include <boost/numeric/conversion/detail/preprocessed/numeric_cast_traits_common.hpp>
  11. #if !defined(BOOST_NO_LONG_LONG)
  12. #include <boost/numeric/conversion/detail/preprocessed/numeric_cast_traits_long_long.hpp>
  13. #endif
  14. #else
  15. #if !BOOST_PP_IS_ITERATING
  16. #include <boost/preprocessor/seq/elem.hpp>
  17. #include <boost/preprocessor/seq/size.hpp>
  18. #include <boost/preprocessor/iteration/iterate.hpp>
  19. #if defined(__WAVE__) && defined(BOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES)
  20. #pragma wave option(preserve: 2, line: 0, output: "preprocessed/numeric_cast_traits_common.hpp")
  21. #endif
  22. //
  23. //! Copyright (c) 2011-2012
  24. //! Brandon Kohn
  25. //
  26. // Distributed under the Boost Software License, Version 1.0. (See
  27. // accompanying file LICENSE_1_0.txt or copy at
  28. // http://www.boost.org/LICENSE_1_0.txt)
  29. //
  30. #if defined(__WAVE__) && defined(BOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES)
  31. #pragma wave option(preserve: 1)
  32. #endif
  33. //! These are the assumed common built in fundamental types (not typedefs/macros.)
  34. #define BOOST_NUMERIC_CONVERSION_BASE_BUILTIN_TYPES() \
  35. (char) \
  36. (signed char) \
  37. (unsigned char) \
  38. (short) \
  39. (unsigned short) \
  40. (int) \
  41. (unsigned int) \
  42. (long) \
  43. (unsigned long) \
  44. (float) \
  45. (double) \
  46. (long double) \
  47. /***/
  48. #define BOOST_NUMERIC_CONVERSION_SEQ_A() BOOST_NUMERIC_CONVERSION_BASE_BUILTIN_TYPES()
  49. #define BOOST_NUMERIC_CONVERSION_SEQ_B() BOOST_NUMERIC_CONVERSION_BASE_BUILTIN_TYPES()
  50. namespace boost { namespace numeric {
  51. #define BOOST_PP_ITERATION_PARAMS_1 (3, (0, BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(BOOST_NUMERIC_CONVERSION_SEQ_A())), <boost/numeric/conversion/detail/numeric_cast_traits.hpp>))
  52. #include BOOST_PP_ITERATE()
  53. }}//namespace boost::numeric;
  54. #if defined(__WAVE__) && defined(BOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES)
  55. #pragma wave option(output: null)
  56. #endif
  57. #if ( defined(__WAVE__) && defined(BOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES) ) || !defined(BOOST_NO_LONG_LONG)
  58. #undef BOOST_NUMERIC_CONVERSION_SEQ_A
  59. #undef BOOST_NUMERIC_CONVERSION_SEQ_B
  60. #if defined(__WAVE__) && defined(BOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES)
  61. #pragma wave option(preserve: 2, line: 0, output: "preprocessed/numeric_cast_traits_long_long.hpp")
  62. #endif
  63. //
  64. //! Copyright (c) 2011-2012
  65. //! Brandon Kohn
  66. //
  67. // Distributed under the Boost Software License, Version 1.0. (See
  68. // accompanying file LICENSE_1_0.txt or copy at
  69. // http://www.boost.org/LICENSE_1_0.txt)
  70. //
  71. #if defined(__WAVE__) && defined(BOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES)
  72. #pragma wave option(preserve: 1)
  73. #endif
  74. namespace boost { namespace numeric {
  75. #define BOOST_NUMERIC_CONVERSION_SEQ_A() BOOST_NUMERIC_CONVERSION_BASE_BUILTIN_TYPES()(boost::long_long_type)(boost::ulong_long_type)
  76. #define BOOST_NUMERIC_CONVERSION_SEQ_B() (boost::long_long_type)(boost::ulong_long_type)
  77. #define BOOST_PP_ITERATION_PARAMS_1 (3, (0, BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(BOOST_NUMERIC_CONVERSION_SEQ_A())), <boost/numeric/conversion/detail/numeric_cast_traits.hpp>))
  78. #include BOOST_PP_ITERATE()
  79. }}//namespace boost::numeric;
  80. #if defined(__WAVE__) && defined(BOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES)
  81. #pragma wave option(output: null)
  82. #endif
  83. #endif
  84. #undef BOOST_NUMERIC_CONVERSION_BASE_BUILTIN_TYPES
  85. #undef BOOST_NUMERIC_CONVERSION_SEQ_A
  86. #undef BOOST_NUMERIC_CONVERSION_SEQ_B
  87. #elif BOOST_PP_ITERATION_DEPTH() == 1
  88. #define BOOST_PP_ITERATION_PARAMS_2 (3, (0, BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(BOOST_NUMERIC_CONVERSION_SEQ_B())), <boost/numeric/conversion/detail/numeric_cast_traits.hpp>))
  89. #include BOOST_PP_ITERATE()
  90. #elif BOOST_PP_ITERATION_DEPTH() == 2
  91. //! Generate default traits for the specified source and target.
  92. #define BOOST_NUMERIC_CONVERSION_A BOOST_PP_FRAME_ITERATION(1)
  93. #define BOOST_NUMERIC_CONVERSION_B BOOST_PP_FRAME_ITERATION(2)
  94. template <>
  95. struct numeric_cast_traits
  96. <
  97. BOOST_PP_SEQ_ELEM(BOOST_NUMERIC_CONVERSION_A, BOOST_NUMERIC_CONVERSION_SEQ_A())
  98. , BOOST_PP_SEQ_ELEM(BOOST_NUMERIC_CONVERSION_B, BOOST_NUMERIC_CONVERSION_SEQ_B())
  99. >
  100. {
  101. typedef def_overflow_handler overflow_policy;
  102. typedef UseInternalRangeChecker range_checking_policy;
  103. typedef Trunc<BOOST_PP_SEQ_ELEM(BOOST_NUMERIC_CONVERSION_B, BOOST_NUMERIC_CONVERSION_SEQ_B())> rounding_policy;
  104. };
  105. #undef BOOST_NUMERIC_CONVERSION_A
  106. #undef BOOST_NUMERIC_CONVERSION_B
  107. #endif//! Depth 2.
  108. #endif// BOOST_NUMERIC_CONVERSION_DONT_USE_PREPROCESSED_FILES