]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/spirit/home/support/numeric_traits.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / spirit / home / support / numeric_traits.hpp
1 // Copyright (c) 2001-2011 Hartmut Kaiser
2 //
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 #if !defined(BOOST_SPIRIT_NUMERIC_TRAITS_JAN_07_2011_0722AM)
7 #define BOOST_SPIRIT_NUMERIC_TRAITS_JAN_07_2011_0722AM
8
9 #if defined(_MSC_VER)
10 #pragma once
11 #endif
12
13 #include <boost/config.hpp>
14 #include <boost/limits.hpp>
15 #include <boost/mpl/bool.hpp>
16
17 namespace boost { namespace spirit { namespace traits
18 {
19 ///////////////////////////////////////////////////////////////////////////
20 // Determine if T is a boolean type
21 ///////////////////////////////////////////////////////////////////////////
22 template <typename T>
23 struct is_bool : mpl::false_ {};
24
25 template <typename T>
26 struct is_bool<T const> : is_bool<T> {};
27
28 template <>
29 struct is_bool<bool> : mpl::true_ {};
30
31 ///////////////////////////////////////////////////////////////////////////
32 // Determine if T is a signed integer type
33 ///////////////////////////////////////////////////////////////////////////
34 template <typename T>
35 struct is_int : mpl::false_ {};
36
37 template <typename T>
38 struct is_int<T const> : is_int<T> {};
39
40 template <>
41 struct is_int<short> : mpl::true_ {};
42
43 template <>
44 struct is_int<int> : mpl::true_ {};
45
46 template <>
47 struct is_int<long> : mpl::true_ {};
48
49 #ifdef BOOST_HAS_LONG_LONG
50 template <>
51 struct is_int<boost::long_long_type> : mpl::true_ {};
52 #endif
53
54 ///////////////////////////////////////////////////////////////////////////
55 // Determine if T is an unsigned integer type
56 ///////////////////////////////////////////////////////////////////////////
57 template <typename T>
58 struct is_uint : mpl::false_ {};
59
60 template <typename T>
61 struct is_uint<T const> : is_uint<T> {};
62
63 #if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
64 template <>
65 struct is_uint<unsigned short> : mpl::true_ {};
66 #endif
67
68 template <>
69 struct is_uint<unsigned int> : mpl::true_ {};
70
71 template <>
72 struct is_uint<unsigned long> : mpl::true_ {};
73
74 #ifdef BOOST_HAS_LONG_LONG
75 template <>
76 struct is_uint<boost::ulong_long_type> : mpl::true_ {};
77 #endif
78
79 ///////////////////////////////////////////////////////////////////////////
80 // Determine if T is a floating point type
81 ///////////////////////////////////////////////////////////////////////////
82 template <typename T>
83 struct is_real : mpl::false_ {};
84
85 template <typename T>
86 struct is_real<T const> : is_uint<T> {};
87
88 template <>
89 struct is_real<float> : mpl::true_ {};
90
91 template <>
92 struct is_real<double> : mpl::true_ {};
93
94 template <>
95 struct is_real<long double> : mpl::true_ {};
96
97 ///////////////////////////////////////////////////////////////////////////
98 // customization points for numeric operations
99 ///////////////////////////////////////////////////////////////////////////
100 template <typename T, typename Enable = void>
101 struct absolute_value;
102
103 template <typename T, typename Enable = void>
104 struct is_negative;
105
106 template <typename T, typename Enable = void>
107 struct is_zero;
108
109 template <typename T, typename Enable = void>
110 struct pow10_helper;
111
112 template <typename T, typename Enable = void>
113 struct is_nan;
114
115 template <typename T, typename Enable = void>
116 struct is_infinite;
117
118 template <typename T, typename Enable = void>
119 struct check_overflow : mpl::bool_<std::numeric_limits<T>::is_bounded> {};
120 }}}
121
122 #endif