1 | // Boost.Units - A C++ library for zero-overhead dimensional analysis and |
---|---|
2 | // unit/quantity manipulation and conversion |
3 | // |
4 | // Copyright (C) 2003-2008 Matthias Christian Schabel |
5 | // Copyright (C) 2007-2008 Steven Watanabe |
6 | // |
7 | // Distributed under the Boost Software License, Version 1.0. (See |
8 | // accompanying file LICENSE_1_0.txt or copy at |
9 | // http://www.boost.org/LICENSE_1_0.txt) |
10 | |
11 | #ifndef BOOST_UNITS_LIMITS_HPP |
12 | #define BOOST_UNITS_LIMITS_HPP |
13 | |
14 | /// |
15 | /// \file |
16 | /// \brief specialize std::numeric_limits for units. |
17 | /// |
18 | |
19 | #include <limits> |
20 | |
21 | #include <boost/config.hpp> |
22 | #include <boost/units/units_fwd.hpp> |
23 | |
24 | namespace std { |
25 | |
26 | template<class Unit, class T> |
27 | class numeric_limits< ::boost::units::quantity<Unit, T> > |
28 | { |
29 | public: |
30 | typedef ::boost::units::quantity<Unit, T> quantity_type; |
31 | static const bool is_specialized = std::numeric_limits<T>::is_specialized; |
32 | static quantity_type (min)() { return(quantity_type::from_value((std::numeric_limits<T>::min)())); } |
33 | static quantity_type (max)() { return(quantity_type::from_value((std::numeric_limits<T>::max)())); } |
34 | #ifndef BOOST_NO_CXX11_NUMERIC_LIMITS |
35 | static quantity_type (lowest)() { return(quantity_type::from_value((std::numeric_limits<T>::lowest)())); } |
36 | #endif |
37 | static const int digits = std::numeric_limits<T>::digits; |
38 | static const int digits10 = std::numeric_limits<T>::digits10; |
39 | #ifndef BOOST_NO_CXX11_NUMERIC_LIMITS |
40 | static const int max_digits10 = std::numeric_limits<T>::max_digits10; |
41 | #endif |
42 | static const bool is_signed = std::numeric_limits<T>::is_signed; |
43 | static const bool is_integer = std::numeric_limits<T>::is_integer; |
44 | static const bool is_exact = std::numeric_limits<T>::is_exact; |
45 | static const int radix = std::numeric_limits<T>::radix; |
46 | static quantity_type epsilon() { return(quantity_type::from_value(std::numeric_limits<T>::epsilon())); } |
47 | static quantity_type round_error() { return(quantity_type::from_value(std::numeric_limits<T>::round_error())); } |
48 | static const int min_exponent = std::numeric_limits<T>::min_exponent; |
49 | static const int min_exponent10 = std::numeric_limits<T>::min_exponent10; |
50 | static const int max_exponent = std::numeric_limits<T>::max_exponent; |
51 | static const int max_exponent10 = std::numeric_limits<T>::max_exponent10; |
52 | static const bool has_infinity = std::numeric_limits<T>::has_infinity; |
53 | static const bool has_quiet_NaN = std::numeric_limits<T>::has_quiet_NaN; |
54 | static const bool has_signaling_NaN = std::numeric_limits<T>::has_signaling_NaN; |
55 | static const bool has_denorm_loss = std::numeric_limits<T>::has_denorm_loss; |
56 | static quantity_type infinity() { return(quantity_type::from_value(std::numeric_limits<T>::infinity())); } |
57 | static quantity_type quiet_NaN() { return(quantity_type::from_value(std::numeric_limits<T>::quiet_NaN())); } |
58 | static quantity_type signaling_NaN() { return(quantity_type::from_value(std::numeric_limits<T>::signaling_NaN())); } |
59 | static quantity_type denorm_min() { return(quantity_type::from_value(std::numeric_limits<T>::denorm_min())); } |
60 | static const bool is_iec559 = std::numeric_limits<T>::is_iec559; |
61 | static const bool is_bounded = std::numeric_limits<T>::is_bounded; |
62 | static const bool is_modulo = std::numeric_limits<T>::is_modulo; |
63 | static const bool traps = std::numeric_limits<T>::traps; |
64 | static const bool tinyness_before = std::numeric_limits<T>::tinyness_before; |
65 | #if defined(_STLP_STATIC_CONST_INIT_BUG) |
66 | static const int has_denorm = std::numeric_limits<T>::has_denorm; |
67 | static const int round_style = std::numeric_limits<T>::round_style; |
68 | #else |
69 | static const float_denorm_style has_denorm = std::numeric_limits<T>::has_denorm; |
70 | static const float_round_style round_style = std::numeric_limits<T>::round_style; |
71 | #endif |
72 | }; |
73 | |
74 | } |
75 | |
76 | #endif // BOOST_UNITS_LIMITS_HPP |
77 |