]> git.sesse.net Git - casparcg/blob - dependencies/boost/boost/spirit/home/support/numeric_traits.hpp
Manually merged pull request #222
[casparcg] / dependencies / 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/mpl/bool.hpp>
15
16 namespace boost { namespace spirit { namespace traits
17 {
18     ///////////////////////////////////////////////////////////////////////////
19     // Determine if T is a boolean type
20     ///////////////////////////////////////////////////////////////////////////
21     template <typename T>
22     struct is_bool : mpl::false_ {};
23
24     template <typename T>
25     struct is_bool<T const> : is_bool<T> {};
26
27     template <>
28     struct is_bool<bool> : mpl::true_ {};
29
30     ///////////////////////////////////////////////////////////////////////////
31     // Determine if T is a signed integer type
32     ///////////////////////////////////////////////////////////////////////////
33     template <typename T>
34     struct is_int : mpl::false_ {};
35
36     template <typename T>
37     struct is_int<T const> : is_int<T> {};
38
39     template <>
40     struct is_int<short> : mpl::true_ {};
41
42     template <>
43     struct is_int<int> : mpl::true_ {};
44
45     template <>
46     struct is_int<long> : mpl::true_ {};
47
48 #ifdef BOOST_HAS_LONG_LONG
49     template <>
50     struct is_int<boost::long_long_type> : mpl::true_ {};
51 #endif
52
53     ///////////////////////////////////////////////////////////////////////////
54     // Determine if T is an unsigned integer type
55     ///////////////////////////////////////////////////////////////////////////
56     template <typename T>
57     struct is_uint : mpl::false_ {};
58
59     template <typename T>
60     struct is_uint<T const> : is_uint<T> {};
61
62 #if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
63     template <>
64     struct is_uint<unsigned short> : mpl::true_ {};
65 #endif
66
67     template <>
68     struct is_uint<unsigned int> : mpl::true_ {};
69
70     template <>
71     struct is_uint<unsigned long> : mpl::true_ {};
72
73 #ifdef BOOST_HAS_LONG_LONG
74     template <>
75     struct is_uint<boost::ulong_long_type> : mpl::true_ {};
76 #endif
77
78     ///////////////////////////////////////////////////////////////////////////
79     // Determine if T is a floating point type
80     ///////////////////////////////////////////////////////////////////////////
81     template <typename T>
82     struct is_real : mpl::false_ {};
83
84     template <typename T>
85     struct is_real<T const> : is_uint<T> {};
86
87     template <>
88     struct is_real<float> : mpl::true_ {};
89
90     template <>
91     struct is_real<double> : mpl::true_ {};
92
93     template <>
94     struct is_real<long double> : mpl::true_ {};
95
96     ///////////////////////////////////////////////////////////////////////////
97     // customization points for numeric operations
98     ///////////////////////////////////////////////////////////////////////////
99     template <typename T, typename Enable = void>
100     struct absolute_value;
101
102     template <typename T, typename Enable = void>
103     struct is_negative;
104
105     template <typename T, typename Enable = void>
106     struct is_zero;
107
108     template <typename T, typename Enable = void>
109     struct pow10_helper;
110
111     template <typename T, typename Enable = void>
112     struct is_nan;
113
114     template <typename T, typename Enable = void>
115     struct is_infinite;
116 }}}
117
118 #endif