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