1 // Copyright (c) 2001-2011 Hartmut Kaiser
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)
6 #if !defined(BOOST_SPIRIT_NUMERIC_TRAITS_JAN_07_2011_0722AM)
7 #define BOOST_SPIRIT_NUMERIC_TRAITS_JAN_07_2011_0722AM
13 #include <boost/config.hpp>
14 #include <boost/mpl/bool.hpp>
16 namespace boost { namespace spirit { namespace traits
18 ///////////////////////////////////////////////////////////////////////////
19 // Determine if T is a boolean type
20 ///////////////////////////////////////////////////////////////////////////
22 struct is_bool : mpl::false_ {};
25 struct is_bool<T const> : is_bool<T> {};
28 struct is_bool<bool> : mpl::true_ {};
30 ///////////////////////////////////////////////////////////////////////////
31 // Determine if T is a signed integer type
32 ///////////////////////////////////////////////////////////////////////////
34 struct is_int : mpl::false_ {};
37 struct is_int<T const> : is_int<T> {};
40 struct is_int<short> : mpl::true_ {};
43 struct is_int<int> : mpl::true_ {};
46 struct is_int<long> : mpl::true_ {};
48 #ifdef BOOST_HAS_LONG_LONG
50 struct is_int<boost::long_long_type> : mpl::true_ {};
53 ///////////////////////////////////////////////////////////////////////////
54 // Determine if T is an unsigned integer type
55 ///////////////////////////////////////////////////////////////////////////
57 struct is_uint : mpl::false_ {};
60 struct is_uint<T const> : is_uint<T> {};
62 #if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
64 struct is_uint<unsigned short> : mpl::true_ {};
68 struct is_uint<unsigned int> : mpl::true_ {};
71 struct is_uint<unsigned long> : mpl::true_ {};
73 #ifdef BOOST_HAS_LONG_LONG
75 struct is_uint<boost::ulong_long_type> : mpl::true_ {};
78 ///////////////////////////////////////////////////////////////////////////
79 // Determine if T is a floating point type
80 ///////////////////////////////////////////////////////////////////////////
82 struct is_real : mpl::false_ {};
85 struct is_real<T const> : is_uint<T> {};
88 struct is_real<float> : mpl::true_ {};
91 struct is_real<double> : mpl::true_ {};
94 struct is_real<long double> : mpl::true_ {};
96 ///////////////////////////////////////////////////////////////////////////
97 // customization points for numeric operations
98 ///////////////////////////////////////////////////////////////////////////
99 template <typename T, typename Enable = void>
100 struct absolute_value;
102 template <typename T, typename Enable = void>
105 template <typename T, typename Enable = void>
108 template <typename T, typename Enable = void>
111 template <typename T, typename Enable = void>
114 template <typename T, typename Enable = void>