]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/numeric/conversion/test/compile_fail/built_in_numeric_cast_traits.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / numeric / conversion / test / compile_fail / built_in_numeric_cast_traits.cpp
CommitLineData
7c673cae
FG
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
10#include <boost/operators.hpp>
11#include <boost/numeric/conversion/cast.hpp>
12#include <boost/preprocessor/control/iif.hpp>
13#include <boost/preprocessor/comparison/less.hpp>
14#include <boost/preprocessor/comparison/not_equal.hpp>
15#include <boost/preprocessor/repetition/for.hpp>
16#include <boost/preprocessor/tuple/elem.hpp>
17#include <boost/preprocessor/seq/elem.hpp>
18#include <boost/preprocessor/seq/size.hpp>
7c673cae
FG
19
20//! Generate default traits for the specified source and target.
21#define BOOST_NUMERIC_CONVERSION_GENERATE_CAST_TRAITS(r, state) \
22template <> \
23struct numeric_cast_traits< \
24 BOOST_PP_SEQ_ELEM( BOOST_PP_TUPLE_ELEM(4,0,state) \
25 , BOOST_PP_TUPLE_ELEM(4,3,state) ) \
26 , BOOST_PP_TUPLE_ELEM(4,2,state)> \
27{ \
28 typedef def_overflow_handler overflow_policy; \
29 typedef UseInternalRangeChecker range_checking_policy; \
30 typedef Trunc<BOOST_PP_TUPLE_ELEM(4,2,state)> rounding_policy; \
31}; \
32/***/
33
34#define BOOST_NUMERIC_CONVERSION_TUPLE_SENTINAL(r, state) \
35 BOOST_PP_LESS \
36 ( \
37 BOOST_PP_TUPLE_ELEM(4,0,state) \
38 , BOOST_PP_TUPLE_ELEM(4,1,state) \
39 ) \
40/***/
41
42#define BOOST_NUMERIC_CONVERSION_INC_OP(r, state) \
43 ( \
44 BOOST_PP_INC(BOOST_PP_TUPLE_ELEM(4,0,state)) \
45 , BOOST_PP_TUPLE_ELEM(4,1,state) \
46 , BOOST_PP_TUPLE_ELEM(4,2,state) \
47 , BOOST_PP_TUPLE_ELEM(4,3,state) \
48 ) \
49/***/
50
51#define BOOST_NUMERIC_CONVERSION_GENERATE_CAST_TARGET_STEP(r, state) \
52 BOOST_PP_FOR \
53 ( \
54 ( \
55 0 \
56 , BOOST_PP_TUPLE_ELEM(4,1,state) \
57 , BOOST_PP_SEQ_ELEM(BOOST_PP_TUPLE_ELEM(4,0,state),BOOST_PP_TUPLE_ELEM(4,2,state)) \
58 , BOOST_PP_TUPLE_ELEM(4,2,state) \
59 ) \
60 , BOOST_NUMERIC_CONVERSION_TUPLE_SENTINAL \
61 , BOOST_NUMERIC_CONVERSION_INC_OP \
62 , BOOST_NUMERIC_CONVERSION_GENERATE_CAST_TRAITS \
63 ) \
64/***/
65
66#define BOOST_NUMERIC_CONVERSION_GENERATE_BUILTIN_CAST_TRAITS(types) \
67 BOOST_PP_FOR \
68 ( \
69 (0,BOOST_PP_SEQ_SIZE(types),types,_) \
70 , BOOST_NUMERIC_CONVERSION_TUPLE_SENTINAL \
71 , BOOST_NUMERIC_CONVERSION_INC_OP \
72 , BOOST_NUMERIC_CONVERSION_GENERATE_CAST_TARGET_STEP \
73 ) \
74/***/
75
76namespace boost { namespace numeric {
77#if !defined( BOOST_NO_INT64_T )
78 //! Generate the specializations for the built-in types.
79 BOOST_NUMERIC_CONVERSION_GENERATE_BUILTIN_CAST_TRAITS
80 (
81 (char)
82 (boost::int8_t)
83 (boost::uint8_t)
84 (boost::int16_t)
85 (boost::uint16_t)
86 (boost::int32_t)
87 (boost::uint32_t)
88 (boost::int64_t)
89 (boost::uint64_t)
90 (float)
91 (double)
92 (long double)
93 )
94#else
95 BOOST_NUMERIC_CONVERSION_GENERATE_BUILTIN_CAST_TRAITS
96 (
97 (char)
98 (boost::int8_t)
99 (boost::uint8_t)
100 (boost::int16_t)
101 (boost::uint16_t)
102 (boost::int32_t)
103 (boost::uint32_t)
104 (float)
105 (double)
106 (long double)
107 )
108#endif
109}}//namespace boost::numeric;
110
7c673cae
FG
111#undef BOOST_NUMERIC_CONVERSION_GENERATE_BUILTIN_CAST_TRAITS
112#undef BOOST_NUMERIC_CONVERSION_GENERATE_CAST_TARGET_STEP
113#undef BOOST_NUMERIC_CONVERSION_INC_OP
114#undef BOOST_NUMERIC_CONVERSION_TUPLE_SENTINAL
115#undef BOOST_NUMERIC_CONVERSION_GENERATE_CAST_TRAITS