]> git.lyx.org Git - features.git/blob - boost/boost/numeric/conversion/detail/numeric_cast_traits.hpp
9ac7950163598ae3879bd1060b5d88e4ffe38f7d
[features.git] / boost / boost / numeric / conversion / detail / numeric_cast_traits.hpp
1 //
2 //! Copyright (c) 2011
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.hpp>
11 #else
12 #if !BOOST_PP_IS_ITERATING
13
14     #include <boost/preprocessor/iteration/iterate.hpp>
15     #include <boost/preprocessor/seq/elem.hpp>
16     #include <boost/preprocessor/seq/size.hpp>
17
18     #if defined(__WAVE__) && defined(BOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES)
19         #pragma wave option(preserve: 2, line: 0, output: "preprocessed/numeric_cast_traits.hpp")
20     #endif
21
22 //
23 //! Copyright (c) 2011
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
34     //! Generate the specializations for the built-in types.
35     #if !defined( BOOST_NO_INT64_T )    
36         #define BOOST_NUMERIC_CONVERSION_BUILTIN_TYPES() \
37                 (char)                                   \
38                 (boost::int8_t)                          \
39                 (boost::uint8_t)                         \
40                 (boost::int16_t)                         \
41                 (boost::uint16_t)                        \
42                 (boost::int32_t)                         \
43                 (boost::uint32_t)                        \
44                 (boost::int64_t)                         \
45                 (boost::uint64_t)                        \
46                 (float)                                  \
47                 (double)                                 \
48                 (long double)                            \
49         /***/
50     #else
51         #define BOOST_NUMERIC_CONVERSION_BUILTIN_TYPES() \
52                 (char)                                   \
53                 (boost::int8_t)                          \
54                 (boost::uint8_t)                         \
55                 (boost::int16_t)                         \
56                 (boost::uint16_t)                        \
57                 (boost::int32_t)                         \
58                 (boost::uint32_t)                        \
59                 (float)                                  \
60                 (double)                                 \
61                 (long double)                            \
62         /***/
63     #endif
64
65 namespace boost { namespace numeric {
66
67     #define BOOST_PP_ITERATION_PARAMS_1 (3, (0, BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(BOOST_NUMERIC_CONVERSION_BUILTIN_TYPES())), <boost/numeric/conversion/detail/numeric_cast_traits.hpp>))
68     #include BOOST_PP_ITERATE()    
69
70 }}//namespace boost::numeric;
71
72     #if defined(__WAVE__) && defined(BOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES)
73         #pragma wave option(output: null)
74     #endif   
75
76     #undef BOOST_NUMERIC_CONVERSION_BUILTIN_TYPES
77
78 #elif BOOST_PP_ITERATION_DEPTH() == 1
79
80    #define BOOST_PP_ITERATION_PARAMS_2 (3, (0, BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(BOOST_NUMERIC_CONVERSION_BUILTIN_TYPES())), <boost/numeric/conversion/detail/numeric_cast_traits.hpp>))
81    #include BOOST_PP_ITERATE()
82        
83 #elif BOOST_PP_ITERATION_DEPTH() == 2
84
85     //! Generate default traits for the specified source and target.
86     #define BOOST_NUMERIC_CONVERSION_A BOOST_PP_FRAME_ITERATION(1)
87     #define BOOST_NUMERIC_CONVERSION_B BOOST_PP_FRAME_ITERATION(2)
88
89     template <>
90     struct numeric_cast_traits
91         <
92             BOOST_PP_SEQ_ELEM(BOOST_NUMERIC_CONVERSION_A, BOOST_NUMERIC_CONVERSION_BUILTIN_TYPES())
93           , BOOST_PP_SEQ_ELEM(BOOST_NUMERIC_CONVERSION_B, BOOST_NUMERIC_CONVERSION_BUILTIN_TYPES())
94         >
95     {
96         typedef def_overflow_handler overflow_policy;
97         typedef UseInternalRangeChecker range_checking_policy;
98         typedef Trunc<BOOST_PP_SEQ_ELEM(BOOST_NUMERIC_CONVERSION_B, BOOST_NUMERIC_CONVERSION_BUILTIN_TYPES())> rounding_policy;
99     };     
100
101     #undef BOOST_NUMERIC_CONVERSION_A
102     #undef BOOST_NUMERIC_CONVERSION_B
103
104 #endif//! Depth 2.
105 #endif// BOOST_NUMERIC_CONVERSION_DONT_USE_PREPROCESSED_FILES