]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/icl/type_traits/is_numeric.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / icl / type_traits / is_numeric.hpp
1 /*-----------------------------------------------------------------------------+
2 Copyright (c) 2010-2010: Joachim Faulhaber
3 +------------------------------------------------------------------------------+
4 Distributed under the Boost Software License, Version 1.0.
5 (See accompanying file LICENCE.txt or copy at
6 http://www.boost.org/LICENSE_1_0.txt)
7 +-----------------------------------------------------------------------------*/
8 #ifndef BOOST_ICL_TYPE_TRAITS_IS_NUMERIC_HPP_JOFA_100322
9 #define BOOST_ICL_TYPE_TRAITS_IS_NUMERIC_HPP_JOFA_100322
10
11 #include <limits>
12 #include <complex>
13 #include <functional>
14 #include <boost/type_traits/is_floating_point.hpp>
15 #include <boost/type_traits/is_integral.hpp>
16
17 namespace boost{ namespace icl
18 {
19
20 template <class Type> struct is_fixed_numeric
21 {
22 typedef is_fixed_numeric type;
23 BOOST_STATIC_CONSTANT(bool, value = (0 < std::numeric_limits<Type>::digits));
24 };
25
26 template <class Type> struct is_std_numeric
27 {
28 typedef is_std_numeric type;
29 BOOST_STATIC_CONSTANT(bool,
30 value = (std::numeric_limits<Type>::is_specialized));
31 };
32
33 template <class Type> struct is_std_integral
34 {
35 typedef is_std_integral type;
36 BOOST_STATIC_CONSTANT(bool,
37 value = (std::numeric_limits<Type>::is_integer));
38 };
39
40 template <class Type> struct is_numeric
41 {
42 typedef is_numeric type;
43 BOOST_STATIC_CONSTANT(bool, value =
44 (mpl::or_< is_std_numeric<Type>
45 , boost::is_integral<Type>
46 , is_std_integral<Type> >::value) );
47 };
48
49 template <class Type>
50 struct is_numeric<std::complex<Type> >
51 {
52 typedef is_numeric type;
53 BOOST_STATIC_CONSTANT(bool, value = true);
54 };
55
56 //--------------------------------------------------------------------------
57 template<class Type, class Compare, bool Enable = false>
58 struct numeric_minimum
59 {
60 static bool is_less_than(Type){ return true; }
61 static bool is_less_than_or(Type, bool){ return true; }
62 };
63
64 template<class Type>
65 struct numeric_minimum<Type, std::less<Type>, true>
66 {
67 static bool is_less_than(Type value)
68 { return std::less<Type>()((std::numeric_limits<Type>::min)(), value); }
69
70 static bool is_less_than_or(Type value, bool cond)
71 { return cond || is_less_than(value); }
72 };
73
74 template<class Type>
75 struct numeric_minimum<Type, std::greater<Type>, true>
76 {
77 static bool is_less_than(Type value)
78 { return std::greater<Type>()((std::numeric_limits<Type>::max)(), value); }
79
80 static bool is_less_than_or(Type value, bool cond)
81 { return cond || is_less_than(value); }
82 };
83
84 //--------------------------------------------------------------------------
85 template<class Type>
86 struct is_non_floating_point
87 {
88 typedef is_non_floating_point type;
89 BOOST_STATIC_CONSTANT(bool, value =
90 (mpl::not_< is_floating_point<Type> >::value));
91 };
92
93 }} // namespace boost icl
94
95 #endif
96
97