Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 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 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 10 | #if !defined(NDNBOOST_NUMERIC_CONVERSION_DONT_USE_PREPROCESSED_FILES) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 11 | |
| 12 | #include <ndnboost/numeric/conversion/detail/preprocessed/numeric_cast_traits_common.hpp> |
| 13 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 14 | #if !defined(NDNBOOST_NO_LONG_LONG) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 15 | #include <ndnboost/numeric/conversion/detail/preprocessed/numeric_cast_traits_long_long.hpp> |
| 16 | #endif |
| 17 | |
| 18 | #else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 19 | #if !NDNBOOST_PP_IS_ITERATING |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 20 | |
| 21 | #include <ndnboost/preprocessor/seq/elem.hpp> |
| 22 | #include <ndnboost/preprocessor/seq/size.hpp> |
| 23 | #include <ndnboost/preprocessor/iteration/iterate.hpp> |
| 24 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 25 | #if defined(__WAVE__) && defined(NDNBOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 26 | #pragma wave option(preserve: 2, line: 0, output: "preprocessed/numeric_cast_traits_common.hpp") |
| 27 | #endif |
| 28 | // |
| 29 | //! Copyright (c) 2011-2012 |
| 30 | //! Brandon Kohn |
| 31 | // |
| 32 | // Distributed under the Boost Software License, Version 1.0. (See |
| 33 | // accompanying file LICENSE_1_0.txt or copy at |
| 34 | // http://www.boost.org/LICENSE_1_0.txt) |
| 35 | // |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 36 | #if defined(__WAVE__) && defined(NDNBOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 37 | #pragma wave option(preserve: 1) |
| 38 | #endif |
| 39 | |
| 40 | //! These are the assumed common built in fundamental types (not typedefs/macros.) |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 41 | #define NDNBOOST_NUMERIC_CONVERSION_BASE_BUILTIN_TYPES() \ |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 42 | (char) \ |
| 43 | (signed char) \ |
| 44 | (unsigned char) \ |
| 45 | (short) \ |
| 46 | (unsigned short) \ |
| 47 | (int) \ |
| 48 | (unsigned int) \ |
| 49 | (long) \ |
| 50 | (unsigned long) \ |
| 51 | (float) \ |
| 52 | (double) \ |
| 53 | (long double) \ |
| 54 | /***/ |
| 55 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 56 | #define NDNBOOST_NUMERIC_CONVERSION_SEQ_A() NDNBOOST_NUMERIC_CONVERSION_BASE_BUILTIN_TYPES() |
| 57 | #define NDNBOOST_NUMERIC_CONVERSION_SEQ_B() NDNBOOST_NUMERIC_CONVERSION_BASE_BUILTIN_TYPES() |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 58 | |
| 59 | namespace ndnboost { namespace numeric { |
| 60 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 61 | #define NDNBOOST_PP_ITERATION_PARAMS_1 (3, (0, NDNBOOST_PP_DEC(NDNBOOST_PP_SEQ_SIZE(NDNBOOST_NUMERIC_CONVERSION_SEQ_A())), <ndnboost/numeric/conversion/detail/numeric_cast_traits.hpp>)) |
| 62 | #include NDNBOOST_PP_ITERATE() |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 63 | |
| 64 | }}//namespace ndnboost::numeric; |
| 65 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 66 | #if defined(__WAVE__) && defined(NDNBOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 67 | #pragma wave option(output: null) |
| 68 | #endif |
| 69 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 70 | #if ( defined(__WAVE__) && defined(NDNBOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES) ) || !defined(NDNBOOST_NO_LONG_LONG) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 71 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 72 | #undef NDNBOOST_NUMERIC_CONVERSION_SEQ_A |
| 73 | #undef NDNBOOST_NUMERIC_CONVERSION_SEQ_B |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 74 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 75 | #if defined(__WAVE__) && defined(NDNBOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 76 | #pragma wave option(preserve: 2, line: 0, output: "preprocessed/numeric_cast_traits_long_long.hpp") |
| 77 | #endif |
| 78 | |
| 79 | // |
| 80 | //! Copyright (c) 2011-2012 |
| 81 | //! Brandon Kohn |
| 82 | // |
| 83 | // Distributed under the Boost Software License, Version 1.0. (See |
| 84 | // accompanying file LICENSE_1_0.txt or copy at |
| 85 | // http://www.boost.org/LICENSE_1_0.txt) |
| 86 | // |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 87 | #if defined(__WAVE__) && defined(NDNBOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 88 | #pragma wave option(preserve: 1) |
| 89 | #endif |
| 90 | |
| 91 | namespace ndnboost { namespace numeric { |
| 92 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 93 | #define NDNBOOST_NUMERIC_CONVERSION_SEQ_A() NDNBOOST_NUMERIC_CONVERSION_BASE_BUILTIN_TYPES()(ndnboost::long_long_type)(ndnboost::ulong_long_type) |
| 94 | #define NDNBOOST_NUMERIC_CONVERSION_SEQ_B() (ndnboost::long_long_type)(ndnboost::ulong_long_type) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 95 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 96 | #define NDNBOOST_PP_ITERATION_PARAMS_1 (3, (0, NDNBOOST_PP_DEC(NDNBOOST_PP_SEQ_SIZE(NDNBOOST_NUMERIC_CONVERSION_SEQ_A())), <ndnboost/numeric/conversion/detail/numeric_cast_traits.hpp>)) |
| 97 | #include NDNBOOST_PP_ITERATE() |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 98 | |
| 99 | }}//namespace ndnboost::numeric; |
| 100 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 101 | #if defined(__WAVE__) && defined(NDNBOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 102 | #pragma wave option(output: null) |
| 103 | #endif |
| 104 | |
| 105 | #endif |
| 106 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 107 | #undef NDNBOOST_NUMERIC_CONVERSION_BASE_BUILTIN_TYPES |
| 108 | #undef NDNBOOST_NUMERIC_CONVERSION_SEQ_A |
| 109 | #undef NDNBOOST_NUMERIC_CONVERSION_SEQ_B |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 110 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 111 | #elif NDNBOOST_PP_ITERATION_DEPTH() == 1 |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 112 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 113 | #define NDNBOOST_PP_ITERATION_PARAMS_2 (3, (0, NDNBOOST_PP_DEC(NDNBOOST_PP_SEQ_SIZE(NDNBOOST_NUMERIC_CONVERSION_SEQ_B())), <ndnboost/numeric/conversion/detail/numeric_cast_traits.hpp>)) |
| 114 | #include NDNBOOST_PP_ITERATE() |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 115 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 116 | #elif NDNBOOST_PP_ITERATION_DEPTH() == 2 |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 117 | |
| 118 | //! Generate default traits for the specified source and target. |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 119 | #define NDNBOOST_NUMERIC_CONVERSION_A NDNBOOST_PP_FRAME_ITERATION(1) |
| 120 | #define NDNBOOST_NUMERIC_CONVERSION_B NDNBOOST_PP_FRAME_ITERATION(2) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 121 | |
| 122 | template <> |
| 123 | struct numeric_cast_traits |
| 124 | < |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 125 | NDNBOOST_PP_SEQ_ELEM(NDNBOOST_NUMERIC_CONVERSION_A, NDNBOOST_NUMERIC_CONVERSION_SEQ_A()) |
| 126 | , NDNBOOST_PP_SEQ_ELEM(NDNBOOST_NUMERIC_CONVERSION_B, NDNBOOST_NUMERIC_CONVERSION_SEQ_B()) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 127 | > |
| 128 | { |
| 129 | typedef def_overflow_handler overflow_policy; |
| 130 | typedef UseInternalRangeChecker range_checking_policy; |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 131 | typedef Trunc<NDNBOOST_PP_SEQ_ELEM(NDNBOOST_NUMERIC_CONVERSION_B, NDNBOOST_NUMERIC_CONVERSION_SEQ_B())> rounding_policy; |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 132 | }; |
| 133 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 134 | #undef NDNBOOST_NUMERIC_CONVERSION_A |
| 135 | #undef NDNBOOST_NUMERIC_CONVERSION_B |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 136 | |
| 137 | #endif//! Depth 2. |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 138 | #endif// NDNBOOST_NUMERIC_CONVERSION_DONT_USE_PREPROCESSED_FILES |