From 7a1974742ac4a34a841dc2e45c72c2757380643b Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Wed, 7 Aug 2013 00:15:09 +0900 Subject: [PATCH] workaround for no c++11 numeric_limits --- sprout/checksum/sum.hpp | 4 +- sprout/compost/formats/as_pcm_wave.hpp | 6 +- sprout/config/stdlib/libcpp.hpp | 3 +- sprout/config/stdlib/libstdcpp3.hpp | 13 +- sprout/cstdlib/ascii_to_int.hpp | 6 +- sprout/cstdlib/str_to_float.hpp | 6 +- sprout/cstdlib/str_to_int.hpp | 6 +- sprout/darkroom/colors/rgb.hpp | 20 +- sprout/darkroom/lights/ambient_light.hpp | 2 +- sprout/darkroom/lights/light_list.hpp | 2 +- sprout/darkroom/lights/parallel_light.hpp | 8 +- sprout/darkroom/lights/point_light.hpp | 8 +- sprout/darkroom/renderers/whitted_style.hpp | 8 +- sprout/detail/integer.hpp | 52 ++-- sprout/detail/integer/integer_mask.hpp | 6 +- sprout/forward_clist.hpp | 4 +- sprout/functional/hash/detail/hash_float.hpp | 14 +- sprout/functional/hash/hash_value_traits.hpp | 14 +- sprout/iterator/counting_iterator.hpp | 4 +- sprout/iterator/generator_iterator.hpp | 4 +- sprout/iterator/value_iterator.hpp | 4 +- sprout/limits.hpp | 277 ++++++++++++++++++ sprout/math/acos.hpp | 4 +- sprout/math/acosh.hpp | 6 +- sprout/math/asin.hpp | 4 +- sprout/math/asinh.hpp | 6 +- sprout/math/atan.hpp | 6 +- sprout/math/atan2.hpp | 22 +- sprout/math/atanh.hpp | 8 +- sprout/math/cbrt.hpp | 6 +- sprout/math/ceil.hpp | 8 +- sprout/math/copysign.hpp | 6 +- sprout/math/cos.hpp | 7 +- sprout/math/cosh.hpp | 6 +- sprout/math/equal_to.hpp | 4 +- sprout/math/erf.hpp | 6 +- sprout/math/erfc.hpp | 4 +- sprout/math/exp.hpp | 6 +- sprout/math/exp10.hpp | 6 +- sprout/math/exp2.hpp | 6 +- sprout/math/expm1.hpp | 6 +- sprout/math/fabs.hpp | 2 +- sprout/math/fdim.hpp | 10 +- sprout/math/float2_exponent.hpp | 4 +- sprout/math/float2_sig_exp.hpp | 6 +- sprout/math/float2_significand.hpp | 6 +- sprout/math/float_exponent.hpp | 4 +- sprout/math/float_sig_exp.hpp | 8 +- sprout/math/float_significand.hpp | 8 +- sprout/math/floor.hpp | 8 +- sprout/math/fma.hpp | 8 +- sprout/math/fmax.hpp | 10 +- sprout/math/fmin.hpp | 10 +- sprout/math/fmod.hpp | 12 +- sprout/math/frac_int.hpp | 4 +- sprout/math/fractional_part.hpp | 4 +- sprout/math/gcd.hpp | 4 +- sprout/math/hypot.hpp | 10 +- sprout/math/iceil.hpp | 10 +- sprout/math/ifloor.hpp | 10 +- sprout/math/integer_part.hpp | 6 +- sprout/math/iround.hpp | 10 +- sprout/math/isinf.hpp | 6 +- sprout/math/issubnormal.hpp | 6 +- sprout/math/itrunc.hpp | 10 +- sprout/math/lcm.hpp | 4 +- sprout/math/ldexp.hpp | 6 +- sprout/math/lgamma.hpp | 8 +- sprout/math/llround.hpp | 4 +- sprout/math/log.hpp | 8 +- sprout/math/log10.hpp | 8 +- sprout/math/log1p.hpp | 8 +- sprout/math/log2.hpp | 8 +- sprout/math/logb.hpp | 42 +-- sprout/math/logb2.hpp | 8 +- sprout/math/lround.hpp | 4 +- sprout/math/pow.hpp | 28 +- sprout/math/quotient.hpp | 6 +- sprout/math/rem_quo.hpp | 12 +- sprout/math/remainder.hpp | 14 +- sprout/math/round.hpp | 8 +- sprout/math/scalbln.hpp | 8 +- sprout/math/scalbn.hpp | 8 +- sprout/math/sin.hpp | 6 +- sprout/math/sinh.hpp | 6 +- sprout/math/sqrt.hpp | 6 +- sprout/math/tan.hpp | 6 +- sprout/math/tanh.hpp | 6 +- sprout/math/tgamma.hpp | 12 +- sprout/math/trunc.hpp | 8 +- sprout/random/detail/const_mod.hpp | 24 +- sprout/random/detail/generator_bits.hpp | 4 +- .../random/detail/signed_unsigned_tools.hpp | 6 +- sprout/random/detail/uniform_int_float.hpp | 10 +- sprout/random/geometric_distribution.hpp | 4 +- sprout/random/inversive_congruential.hpp | 2 +- sprout/random/linear_congruential.hpp | 4 +- sprout/random/normal_distribution.hpp | 6 +- sprout/random/shuffle_order.hpp | 10 +- sprout/random/uniform_01.hpp | 6 +- sprout/random/uniform_int_distribution.hpp | 14 +- sprout/range/adaptor/sawtooth_wave.hpp | 4 +- sprout/range/adaptor/sinusoidal.hpp | 4 +- sprout/range/adaptor/square_wave.hpp | 4 +- sprout/range/adaptor/triangle_wave.hpp | 4 +- sprout/rational/rational.hpp | 4 +- sprout/string/float_to_string.hpp | 6 +- sprout/utility/limited.hpp | 26 +- sprout/uuid/random_generator.hpp | 4 +- testspr/header_all.hpp | 1 + 110 files changed, 727 insertions(+), 436 deletions(-) create mode 100644 sprout/limits.hpp diff --git a/sprout/checksum/sum.hpp b/sprout/checksum/sum.hpp index ac276ff9..1f515b63 100644 --- a/sprout/checksum/sum.hpp +++ b/sprout/checksum/sum.hpp @@ -5,8 +5,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -84,7 +84,7 @@ namespace sprout { } SPROUT_CONSTEXPR value_type checksum() const { - return static_cast(sum_ & std::numeric_limits::max()); + return static_cast(sum_ & sprout::numeric_limits::max()); } SPROUT_CONSTEXPR value_type operator()() const { return checksum(); diff --git a/sprout/compost/formats/as_pcm_wave.hpp b/sprout/compost/formats/as_pcm_wave.hpp index bb6f48ce..65493b94 100644 --- a/sprout/compost/formats/as_pcm_wave.hpp +++ b/sprout/compost/formats/as_pcm_wave.hpp @@ -2,9 +2,9 @@ #define SPROUT_COMPOST_FORMATS_AS_PCM_WAVE_HPP #include -#include #include #include +#include #include #include #include @@ -26,7 +26,7 @@ namespace sprout { public: template SPROUT_CONSTEXPR result_type operator()(T const& x) const { - return static_cast(sprout::clamp(x, -1, 1) * std::numeric_limits::max()); + return static_cast(sprout::clamp(x, -1, 1) * sprout::numeric_limits::max()); } }; template @@ -39,7 +39,7 @@ namespace sprout { public: template SPROUT_CONSTEXPR result_type operator()(T const& x) const { - return static_cast(sprout::clamp((x + 1) / 2, 0, 1) * std::numeric_limits::max()); + return static_cast(sprout::clamp((x + 1) / 2, 0, 1) * sprout::numeric_limits::max()); } }; } // namespace detail diff --git a/sprout/config/stdlib/libcpp.hpp b/sprout/config/stdlib/libcpp.hpp index ab90e833..02abb49c 100644 --- a/sprout/config/stdlib/libcpp.hpp +++ b/sprout/config/stdlib/libcpp.hpp @@ -11,8 +11,9 @@ #define SPROUT_NO_CXX11_ATOMIC_SMART_PTR #include -#if defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION < 1101) +#if defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION <= 1001) # define SPROUT_NO_CXX11_CHAR_TRAITS +# define SPROUT_NO_CXX11_NUMERIC_LIMITS #endif #endif // #ifndef SPROUT_CONFIG_STDLIB_LIBCPP_HPP diff --git a/sprout/config/stdlib/libstdcpp3.hpp b/sprout/config/stdlib/libstdcpp3.hpp index f73b4da7..b80f52ea 100644 --- a/sprout/config/stdlib/libstdcpp3.hpp +++ b/sprout/config/stdlib/libstdcpp3.hpp @@ -26,7 +26,18 @@ #endif #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) || !defined(__GXX_EXPERIMENTAL_CXX0X__) -# define SPROUT_NO_CXX11_NUMERIC_LIMITS +# if defined(__clang__) +# if !__has_feature(cxx_constexpr) || !defined(__GXX_EXPERIMENTAL_CXX0X__) +# define SPROUT_NO_CXX11_CHAR_TRAITS +# define SPROUT_NO_CXX11_NUMERIC_LIMITS +# endif +# else +# define SPROUT_NO_CXX11_CHAR_TRAITS +# define SPROUT_NO_CXX11_NUMERIC_LIMITS +# endif +#endif + +#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) || !defined(__GXX_EXPERIMENTAL_CXX0X__) # define SPROUT_NO_CXX11_HDR_FUTURE # define SPROUT_NO_CXX11_HDR_RANDOM #endif diff --git a/sprout/cstdlib/ascii_to_int.hpp b/sprout/cstdlib/ascii_to_int.hpp index f67a1fb0..49badfd0 100644 --- a/sprout/cstdlib/ascii_to_int.hpp +++ b/sprout/cstdlib/ascii_to_int.hpp @@ -2,9 +2,9 @@ #define SPROUT_CSTDLIB_DECIMAL_TO_INT_HPP #include -#include #include #include +#include #include #include @@ -17,8 +17,8 @@ namespace sprout { ascii_to_int_impl(CStrIterator str, IntType val, bool negative) { return !sprout::ascii::isdigit(*str) ? negative ? -val : val - : val > (std::numeric_limits::max() - (*str - static_cast::value_type>('0')) - (negative ? 1 : 0)) / 10 - ? (negative ? std::numeric_limits::min() : std::numeric_limits::max()) + : val > (sprout::numeric_limits::max() - (*str - static_cast::value_type>('0')) - (negative ? 1 : 0)) / 10 + ? (negative ? sprout::numeric_limits::min() : sprout::numeric_limits::max()) : sprout::detail::ascii_to_int_impl( sprout::next(str), val * 10 + (*str - static_cast::value_type>('0')), diff --git a/sprout/cstdlib/str_to_float.hpp b/sprout/cstdlib/str_to_float.hpp index f32aceb4..9ab71f81 100644 --- a/sprout/cstdlib/str_to_float.hpp +++ b/sprout/cstdlib/str_to_float.hpp @@ -3,9 +3,9 @@ #include #include -#include #include #include +#include #include #include @@ -48,8 +48,8 @@ namespace sprout { long exponent = 0 ) { - return exponent >= std::numeric_limits::min_exponent - && exponent <= std::numeric_limits::max_exponent + return exponent >= sprout::numeric_limits::min_exponent + && exponent <= sprout::numeric_limits::max_exponent ? sprout::detail::str_to_float_impl_scale( str, negative, diff --git a/sprout/cstdlib/str_to_int.hpp b/sprout/cstdlib/str_to_int.hpp index bc9baffd..07813454 100644 --- a/sprout/cstdlib/str_to_int.hpp +++ b/sprout/cstdlib/str_to_int.hpp @@ -6,9 +6,9 @@ #if !defined(_MSC_VER) # include #endif -#include #include #include +#include #include #include #include @@ -21,8 +21,8 @@ namespace sprout { inline SPROUT_CONSTEXPR IntType str_to_int_impl_1(CStrIterator str, int base, IntType val, IntType x, bool negative) { return x == static_cast(-1) ? (negative ? -1 * val : val) - : val > (std::numeric_limits::max() - x - (negative ? 1 : 0)) / base - ? (negative ? std::numeric_limits::min() : std::numeric_limits::max()) + : val > (sprout::numeric_limits::max() - x - (negative ? 1 : 0)) / base + ? (negative ? sprout::numeric_limits::min() : sprout::numeric_limits::max()) : sprout::detail::str_to_int_impl_1( sprout::next(str), base, diff --git a/sprout/darkroom/colors/rgb.hpp b/sprout/darkroom/colors/rgb.hpp index 80f41c51..eecb7c82 100644 --- a/sprout/darkroom/colors/rgb.hpp +++ b/sprout/darkroom/colors/rgb.hpp @@ -2,8 +2,8 @@ #define SPROUT_DARKROOM_COLORS_RGB_HPP #include -#include #include +#include #include #include #include @@ -121,17 +121,17 @@ namespace sprout { rgb_f_to_rgb(RGB_F const& col) { typedef typename sprout::darkroom::access::unit::type unit_type; return sprout::tuples::make( - sprout::darkroom::colors::r(col) < 0 ? std::numeric_limits::min() - : sprout::darkroom::colors::r(col) > 1 ? std::numeric_limits::max() - : sprout::darkroom::colors::r(col) * std::numeric_limits::max() + sprout::darkroom::colors::r(col) < 0 ? sprout::numeric_limits::min() + : sprout::darkroom::colors::r(col) > 1 ? sprout::numeric_limits::max() + : sprout::darkroom::colors::r(col) * sprout::numeric_limits::max() , - sprout::darkroom::colors::g(col) < 0 ? std::numeric_limits::min() - : sprout::darkroom::colors::g(col) > 1 ? std::numeric_limits::max() - : sprout::darkroom::colors::g(col) * std::numeric_limits::max() + sprout::darkroom::colors::g(col) < 0 ? sprout::numeric_limits::min() + : sprout::darkroom::colors::g(col) > 1 ? sprout::numeric_limits::max() + : sprout::darkroom::colors::g(col) * sprout::numeric_limits::max() , - sprout::darkroom::colors::b(col) < 0 ? std::numeric_limits::min() - : sprout::darkroom::colors::b(col) > 1 ? std::numeric_limits::max() - : sprout::darkroom::colors::b(col) * std::numeric_limits::max() + sprout::darkroom::colors::b(col) < 0 ? sprout::numeric_limits::min() + : sprout::darkroom::colors::b(col) > 1 ? sprout::numeric_limits::max() + : sprout::darkroom::colors::b(col) * sprout::numeric_limits::max() ); } } // namespace colors diff --git a/sprout/darkroom/lights/ambient_light.hpp b/sprout/darkroom/lights/ambient_light.hpp index 3d4472ab..3d4dfd29 100644 --- a/sprout/darkroom/lights/ambient_light.hpp +++ b/sprout/darkroom/lights/ambient_light.hpp @@ -1,8 +1,8 @@ #ifndef SPROUT_DARKROOM_LIGHTS_AMBIENT_LIGHT_HPP #define SPROUT_DARKROOM_LIGHTS_AMBIENT_LIGHT_HPP -#include #include +#include #include #include #include diff --git a/sprout/darkroom/lights/light_list.hpp b/sprout/darkroom/lights/light_list.hpp index ffeda36f..3e20d336 100644 --- a/sprout/darkroom/lights/light_list.hpp +++ b/sprout/darkroom/lights/light_list.hpp @@ -1,8 +1,8 @@ #ifndef SPROUT_DARKROOM_LIGHTS_LIGHT_LIST_HPP #define SPROUT_DARKROOM_LIGHTS_LIGHT_LIST_HPP -#include #include +#include #include #include #include diff --git a/sprout/darkroom/lights/parallel_light.hpp b/sprout/darkroom/lights/parallel_light.hpp index 04b5145d..d86ddccb 100644 --- a/sprout/darkroom/lights/parallel_light.hpp +++ b/sprout/darkroom/lights/parallel_light.hpp @@ -1,8 +1,8 @@ #ifndef SPROUT_DARKROOM_LIGHTS_PARALLEL_LIGHT_HPP #define SPROUT_DARKROOM_LIGHTS_PARALLEL_LIGHT_HPP -#include #include +#include #include #include #include @@ -49,9 +49,9 @@ namespace sprout { inter, !sprout::darkroom::intersects::does_intersect(light_ray_inter) || sprout::darkroom::intersects::distance(light_ray_inter) - < std::numeric_limits::epsilon() + < sprout::numeric_limits::epsilon() ? NS_SSCRISK_CEL_OR_SPROUT::max( - std::numeric_limits::epsilon(), + sprout::numeric_limits::epsilon(), sprout::darkroom::coords::dot( dir_, sprout::darkroom::intersects::normal(inter) @@ -76,7 +76,7 @@ namespace sprout { sprout::darkroom::coords::add( sprout::darkroom::coords::scale( dir_, - std::numeric_limits::epsilon() * 256 + sprout::numeric_limits::epsilon() * 256 ), sprout::darkroom::intersects::point_of_intersection(inter) ), diff --git a/sprout/darkroom/lights/point_light.hpp b/sprout/darkroom/lights/point_light.hpp index 6b6b1279..95f02f3d 100644 --- a/sprout/darkroom/lights/point_light.hpp +++ b/sprout/darkroom/lights/point_light.hpp @@ -1,8 +1,8 @@ #ifndef SPROUT_DARKROOM_LIGHTS_POINT_LIGHT_HPP #define SPROUT_DARKROOM_LIGHTS_POINT_LIGHT_HPP -#include #include +#include #include #include #include @@ -55,9 +55,9 @@ namespace sprout { || sprout::darkroom::intersects::distance(light_ray_inter) > sprout::darkroom::coords::length(diff) || sprout::darkroom::intersects::distance(light_ray_inter) - < std::numeric_limits::epsilon() + < sprout::numeric_limits::epsilon() ? NS_SSCRISK_CEL_OR_SPROUT::max( - std::numeric_limits::epsilon(), + sprout::numeric_limits::epsilon(), sprout::darkroom::coords::dot( direction, sprout::darkroom::intersects::normal(inter) @@ -80,7 +80,7 @@ namespace sprout { sprout::darkroom::coords::add( sprout::darkroom::coords::scale( direction, - std::numeric_limits::epsilon() * 256 + sprout::numeric_limits::epsilon() * 256 ), sprout::darkroom::intersects::point_of_intersection(inter) ), diff --git a/sprout/darkroom/renderers/whitted_style.hpp b/sprout/darkroom/renderers/whitted_style.hpp index 9cf748b9..2b64b63c 100644 --- a/sprout/darkroom/renderers/whitted_style.hpp +++ b/sprout/darkroom/renderers/whitted_style.hpp @@ -2,9 +2,9 @@ #define SPROUT_DARKROOM_RENDERERS_WHITTED_STYLE_HPP #include -#include #include #include +#include #include #include #include @@ -45,12 +45,12 @@ namespace sprout { sprout::darkroom::intersects::point_of_intersection(inter), sprout::darkroom::coords::scale( reflect_dir, - std::numeric_limits::type>::epsilon() * 256 + sprout::numeric_limits::type>::epsilon() * 256 ) // ??? // sprout::darkroom::coords::scale( // sprout::darkroom::intersects::normal(inter), -// std::numeric_limits::type>::epsilon() * 256 +// sprout::numeric_limits::type>::epsilon() * 256 // ) ), reflect_dir @@ -77,7 +77,7 @@ namespace sprout { return depth_max > 0 && sprout::darkroom::intersects::does_intersect(inter) && sprout::darkroom::materials::reflection(sprout::darkroom::intersects::material(inter)) - > std::numeric_limits::epsilon() + > sprout::numeric_limits::epsilon() ? color_1( camera, objs, lights, ray, inter, tracer, diff --git a/sprout/detail/integer.hpp b/sprout/detail/integer.hpp index 89bb5467..234a5bc2 100644 --- a/sprout/detail/integer.hpp +++ b/sprout/detail/integer.hpp @@ -2,8 +2,8 @@ #define SPROUT_DETAIL_INTEGER_HPP #include -#include #include +#include namespace sprout { namespace detail { @@ -115,11 +115,11 @@ namespace sprout { { typedef typename sprout::detail::int_least_helper< 0 - + (Bits - 1 <= std::numeric_limits::digits) - + (Bits - 1 <= std::numeric_limits::digits) - + (Bits - 1 <= std::numeric_limits::digits) - + (Bits - 1 <= std::numeric_limits::digits) - + (Bits - 1 <= std::numeric_limits::digits) + + (Bits - 1 <= sprout::numeric_limits::digits) + + (Bits - 1 <= sprout::numeric_limits::digits) + + (Bits - 1 <= sprout::numeric_limits::digits) + + (Bits - 1 <= sprout::numeric_limits::digits) + + (Bits - 1 <= sprout::numeric_limits::digits) >::least least; typedef typename sprout::detail::int_fast_t::type fast; }; @@ -129,11 +129,11 @@ namespace sprout { { typedef typename sprout::detail::int_least_helper< 5 - + (Bits <= std::numeric_limits::digits) - + (Bits <= std::numeric_limits::digits) - + (Bits <= std::numeric_limits::digits) - + (Bits <= std::numeric_limits::digits) - + (Bits <= std::numeric_limits::digits) + + (Bits <= sprout::numeric_limits::digits) + + (Bits <= sprout::numeric_limits::digits) + + (Bits <= sprout::numeric_limits::digits) + + (Bits <= sprout::numeric_limits::digits) + + (Bits <= sprout::numeric_limits::digits) >::least least; typedef typename sprout::detail::int_fast_t::type fast; }; @@ -142,11 +142,11 @@ namespace sprout { struct int_max_value_t { typedef typename sprout::detail::int_least_helper< 0 - + (MaxValue <= std::numeric_limits::max()) - + (MaxValue <= std::numeric_limits::max()) - + (MaxValue <= std::numeric_limits::max()) - + (MaxValue <= std::numeric_limits::max()) - + (MaxValue <= std::numeric_limits::max()) + + (MaxValue <= sprout::numeric_limits::max()) + + (MaxValue <= sprout::numeric_limits::max()) + + (MaxValue <= sprout::numeric_limits::max()) + + (MaxValue <= sprout::numeric_limits::max()) + + (MaxValue <= sprout::numeric_limits::max()) >::least least; typedef typename sprout::detail::int_fast_t::type fast; }; @@ -154,11 +154,11 @@ namespace sprout { struct int_min_value_t { typedef typename sprout::detail::int_least_helper< 0 - + (MinValue >= std::numeric_limits::min()) - + (MinValue >= std::numeric_limits::min()) - + (MinValue >= std::numeric_limits::min()) - + (MinValue >= std::numeric_limits::min()) - + (MinValue >= std::numeric_limits::min()) + + (MinValue >= sprout::numeric_limits::min()) + + (MinValue >= sprout::numeric_limits::min()) + + (MinValue >= sprout::numeric_limits::min()) + + (MinValue >= sprout::numeric_limits::min()) + + (MinValue >= sprout::numeric_limits::min()) >::least least; typedef typename sprout::detail::int_fast_t::type fast; }; @@ -167,11 +167,11 @@ namespace sprout { struct uint_value_t { typedef typename sprout::detail::int_least_helper< 5 - + (MaxValue <= std::numeric_limits::max()) - + (MaxValue <= std::numeric_limits::max()) - + (MaxValue <= std::numeric_limits::max()) - + (MaxValue <= std::numeric_limits::max()) - + (MaxValue <= std::numeric_limits::max()) + + (MaxValue <= sprout::numeric_limits::max()) + + (MaxValue <= sprout::numeric_limits::max()) + + (MaxValue <= sprout::numeric_limits::max()) + + (MaxValue <= sprout::numeric_limits::max()) + + (MaxValue <= sprout::numeric_limits::max()) >::least least; typedef typename sprout::detail::int_fast_t::type fast; }; diff --git a/sprout/detail/integer/integer_mask.hpp b/sprout/detail/integer/integer_mask.hpp index e9a8989c..b1200b0a 100644 --- a/sprout/detail/integer/integer_mask.hpp +++ b/sprout/detail/integer/integer_mask.hpp @@ -3,8 +3,8 @@ #include #include -#include #include +#include #include namespace sprout { @@ -33,9 +33,9 @@ namespace sprout { #define SPROUT_LOW_BITS_MASK_SPECIALIZE(Type) \ template<> \ - struct low_bits_mask_t::digits> { \ + struct low_bits_mask_t::digits> { \ public: \ - typedef std::numeric_limits limits_type; \ + typedef sprout::numeric_limits limits_type; \ typedef typename sprout::detail::uint_t::least least; \ typedef typename sprout::detail::uint_t::fast fast; \ public: \ diff --git a/sprout/forward_clist.hpp b/sprout/forward_clist.hpp index 7513de13..35225a37 100644 --- a/sprout/forward_clist.hpp +++ b/sprout/forward_clist.hpp @@ -3,9 +3,9 @@ #include #include -#include #include #include +#include #include #include #include @@ -361,7 +361,7 @@ namespace sprout { return !!fst.next; } SPROUT_CONSTEXPR size_type max_size() const SPROUT_NOEXCEPT { - return std::numeric_limits::max(); + return sprout::numeric_limits::max(); } // element access: SPROUT_CXX14_CONSTEXPR reference front() { diff --git a/sprout/functional/hash/detail/hash_float.hpp b/sprout/functional/hash/detail/hash_float.hpp index 4c56d9f3..577390fc 100644 --- a/sprout/functional/hash/detail/hash_float.hpp +++ b/sprout/functional/hash/detail/hash_float.hpp @@ -2,8 +2,8 @@ #define SPROUT_FUNCTIONAL_HASH_DETAIL_HASH_FLOAT_HPP #include -#include #include +#include #include #include #include @@ -21,7 +21,7 @@ namespace sprout { inline SPROUT_CONSTEXPR std::size_t float_hash_value_impl_4(T v, int exp, std::size_t seed, std::size_t length, std::size_t i = 0) { return i != length ? sprout::detail::float_hash_value_impl_4( - sprout::ldexp(v - static_cast(static_cast(v)), std::numeric_limits::digits), + sprout::ldexp(v - static_cast(static_cast(v)), sprout::numeric_limits::digits), exp, sprout::detail::hash_float_combine(seed, static_cast(v)), length, i + 1 ) @@ -32,22 +32,22 @@ namespace sprout { inline SPROUT_CONSTEXPR std::size_t float_hash_value_impl_3(T v, int exp) { return sprout::detail::float_hash_value_impl_4( - sprout::ldexp(v - static_cast(static_cast(v)), std::numeric_limits::digits), + sprout::ldexp(v - static_cast(static_cast(v)), sprout::numeric_limits::digits), exp, static_cast(v), - (std::numeric_limits::digits * sprout::detail::static_log2::radix>::value + std::numeric_limits::digits - 1) - / std::numeric_limits::digits + (sprout::numeric_limits::digits * sprout::detail::static_log2::radix>::value + sprout::numeric_limits::digits - 1) + / sprout::numeric_limits::digits ); } template inline SPROUT_CONSTEXPR std::size_t float_hash_value_impl_2(T v, int exp) { - return sprout::detail::float_hash_value_impl_3(sprout::ldexp(v, std::numeric_limits::digits), exp); + return sprout::detail::float_hash_value_impl_3(sprout::ldexp(v, sprout::numeric_limits::digits), exp); } template inline SPROUT_CONSTEXPR std::size_t float_hash_value_impl_1(P const& p) { return ((p.first) < 0) ? sprout::detail::float_hash_value_impl_2( - -p.first, p.second + (std::numeric_limits::max_exponent - std::numeric_limits::min_exponent) + -p.first, p.second + (sprout::numeric_limits::max_exponent - sprout::numeric_limits::min_exponent) ) : sprout::detail::float_hash_value_impl_2(p.first, p.second) ; diff --git a/sprout/functional/hash/hash_value_traits.hpp b/sprout/functional/hash/hash_value_traits.hpp index 30dfa9dd..a0846151 100644 --- a/sprout/functional/hash/hash_value_traits.hpp +++ b/sprout/functional/hash/hash_value_traits.hpp @@ -2,10 +2,10 @@ #define SPROUT_FUNCTIONAL_HASH_HASH_VALUE_TRAITS_HPP #include -#include #include #include #include +#include #include #include @@ -47,7 +47,7 @@ namespace sprout { length, seed ^ static_cast((positive >> i) + (seed << 6) + (seed >> 2)), positive, - i - std::numeric_limits::digits + i - sprout::numeric_limits::digits ) : seed ^ static_cast(val + (seed << 6) + (seed >> 2)) ; @@ -55,14 +55,14 @@ namespace sprout { template inline SPROUT_CONSTEXPR std::size_t hash_value_signed_1(T val, int length, std::size_t seed, T positive) { - return hash_value_signed_2(val, length, seed, positive, length * std::numeric_limits::digits); + return hash_value_signed_2(val, length, seed, positive, length * sprout::numeric_limits::digits); } template inline SPROUT_CONSTEXPR std::size_t hash_value_signed(T val) { return sprout::hash_detail::hash_value_signed_1( val, - (std::numeric_limits::digits - 1) / std::numeric_limits::digits, + (sprout::numeric_limits::digits - 1) / sprout::numeric_limits::digits, 0, val < 0 ? -1 - val : val ); @@ -76,7 +76,7 @@ namespace sprout { val, length, seed ^ static_cast((val >> i) + (seed << 6) + (seed >> 2)), - i - std::numeric_limits::digits + i - sprout::numeric_limits::digits ) : seed ^ static_cast(val + (seed << 6) + (seed >> 2)) ; @@ -84,14 +84,14 @@ namespace sprout { template inline SPROUT_CONSTEXPR std::size_t hash_value_unsigned_1(T val, int length, std::size_t seed) { - return hash_value_unsigned_2(val, length, seed, length * std::numeric_limits::digits); + return hash_value_unsigned_2(val, length, seed, length * sprout::numeric_limits::digits); } template inline SPROUT_CONSTEXPR std::size_t hash_value_unsigned(T val) { return sprout::hash_detail::hash_value_unsigned_1( val, - (std::numeric_limits::digits - 1) / std::numeric_limits::digits, + (sprout::numeric_limits::digits - 1) / sprout::numeric_limits::digits, 0 ); } diff --git a/sprout/iterator/counting_iterator.hpp b/sprout/iterator/counting_iterator.hpp index e253d04d..18af8acb 100644 --- a/sprout/iterator/counting_iterator.hpp +++ b/sprout/iterator/counting_iterator.hpp @@ -1,11 +1,11 @@ #ifndef SPROUT_ITERATOR_COUNTING_ITERATOR_HPP #define SPROUT_ITERATOR_COUNTING_ITERATOR_HPP -#include #include #include #include #include +#include #include #include #include @@ -36,7 +36,7 @@ namespace sprout { template::value>::type = sprout::enabler> static SPROUT_CONSTEXPR T default_value() { - return std::numeric_limits::max(); + return sprout::numeric_limits::max(); } template::value>::type = sprout::enabler> static SPROUT_CONSTEXPR T diff --git a/sprout/iterator/generator_iterator.hpp b/sprout/iterator/generator_iterator.hpp index e93cd8c5..9d8dc6f0 100644 --- a/sprout/iterator/generator_iterator.hpp +++ b/sprout/iterator/generator_iterator.hpp @@ -2,11 +2,11 @@ #define SPROUT_ITERATOR_GENERATOR_ITERATOR_HPP #include -#include #include #include #include #include +#include #include #include @@ -40,7 +40,7 @@ namespace sprout { {} explicit SPROUT_CONSTEXPR generator_iterator( generator_type const& gen, - difference_type index = std::numeric_limits::max() + difference_type index = sprout::numeric_limits::max() ) : gen_(gen), index_(index) {} diff --git a/sprout/iterator/value_iterator.hpp b/sprout/iterator/value_iterator.hpp index f4b5c42a..335f309d 100644 --- a/sprout/iterator/value_iterator.hpp +++ b/sprout/iterator/value_iterator.hpp @@ -2,11 +2,11 @@ #define SPROUT_ITERATOR_VALUE_ITERATOR_HPP #include -#include #include #include #include #include +#include #include #include #include @@ -62,7 +62,7 @@ namespace sprout { value_iterator(value_iterator const&) = default; explicit SPROUT_CONSTEXPR value_iterator( typename sprout::value_holder::param_type p, - difference_type index = std::numeric_limits::max() + difference_type index = sprout::numeric_limits::max() ) : holder_(p), index_(index) {} diff --git a/sprout/limits.hpp b/sprout/limits.hpp new file mode 100644 index 00000000..5ff72ad0 --- /dev/null +++ b/sprout/limits.hpp @@ -0,0 +1,277 @@ +#ifndef SPROUT_LIMITS_HPP +#define SPROUT_LIMITS_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + // + // numeric_limits + // +#ifdef SPROUT_NO_CXX11_NUMERIC_LIMITS + namespace detail { + template + class numeric_limits_base { + private: + typedef std::numeric_limits impl_type; + public: + static SPROUT_CONSTEXPR bool is_specialized = impl_type::is_specialized; + + static SPROUT_CONSTEXPR int digits = impl_type::digits; + static SPROUT_CONSTEXPR int digits10 = impl_type::digits10; + static SPROUT_CONSTEXPR int max_digits10 = impl_type::max_digits10; + static SPROUT_CONSTEXPR bool is_signed = impl_type::is_signed; + static SPROUT_CONSTEXPR bool is_integer = impl_type::is_integer; + static SPROUT_CONSTEXPR bool is_exact = impl_type::is_exact; + static SPROUT_CONSTEXPR int radix = impl_type::radix; + + static SPROUT_CONSTEXPR int min_exponent = impl_type::min_exponent; + static SPROUT_CONSTEXPR int min_exponent10 = impl_type::min_exponent10; + static SPROUT_CONSTEXPR int max_exponent = impl_type::max_exponent; + static SPROUT_CONSTEXPR int max_exponent10 = impl_type::max_exponent10; + static SPROUT_CONSTEXPR bool has_infinity = impl_type::has_infinity; + static SPROUT_CONSTEXPR bool has_quiet_NaN = impl_type::has_quiet_NaN; + static SPROUT_CONSTEXPR bool has_signaling_NaN = impl_type::has_signaling_NaN; + static SPROUT_CONSTEXPR std::float_denorm_style has_denorm = impl_type::has_denorm; + static SPROUT_CONSTEXPR bool has_denorm_loss = impl_type::has_denorm_loss; + + static SPROUT_CONSTEXPR bool is_iec559 = impl_type::is_iec559; + static SPROUT_CONSTEXPR bool is_bounded = impl_type::is_bounded; + static SPROUT_CONSTEXPR bool is_modulo = impl_type::is_modulo; + static SPROUT_CONSTEXPR bool traps = impl_type::traps; + static SPROUT_CONSTEXPR bool tinyness_before = impl_type::tinyness_before; + static SPROUT_CONSTEXPR std::float_round_style round_style = impl_type::round_style; + }; + + template + class numeric_limits_impl; + template + class numeric_limits_impl + : public sprout::detail::numeric_limits_base + { + private: + typedef std::numeric_limits impl_type; + public: + static SPROUT_CONSTEXPR T min() SPROUT_NOEXCEPT { + return impl_type::min(); + } + static SPROUT_CONSTEXPR T max() SPROUT_NOEXCEPT { + return impl_type::max(); + } + static SPROUT_CONSTEXPR T lowest() SPROUT_NOEXCEPT { + return impl_type::lowest(); + } + + static SPROUT_CONSTEXPR T epsilon() SPROUT_NOEXCEPT { + return impl_type::epsilon(); + } + static SPROUT_CONSTEXPR T round_error() SPROUT_NOEXCEPT { + return impl_type::round_error(); + } + + static SPROUT_CONSTEXPR T infinity() SPROUT_NOEXCEPT { + return impl_type::infinity(); + } + static SPROUT_CONSTEXPR T quiet_NaN() SPROUT_NOEXCEPT { + return impl_type::quiet_NaN(); + } + static SPROUT_CONSTEXPR T signaling_NaN() SPROUT_NOEXCEPT { + return impl_type::signaling_NaN(); + } + static SPROUT_CONSTEXPR T denorm_min() SPROUT_NOEXCEPT { + return impl_type::denorm_min(); + } + }; + template + class numeric_limits_impl + : public sprout::detail::numeric_limits_base + { + public: + static SPROUT_CONSTEXPR T min() SPROUT_NOEXCEPT { + return T(); + } + static SPROUT_CONSTEXPR T max() SPROUT_NOEXCEPT { + return T(); + } + static SPROUT_CONSTEXPR T lowest() SPROUT_NOEXCEPT { + return T(); + } + + static SPROUT_CONSTEXPR T epsilon() SPROUT_NOEXCEPT { + return T(); + } + static SPROUT_CONSTEXPR T round_error() SPROUT_NOEXCEPT { + return T(); + } + + static SPROUT_CONSTEXPR T infinity() SPROUT_NOEXCEPT { + return T(); + } + static SPROUT_CONSTEXPR T quiet_NaN() SPROUT_NOEXCEPT { + return T(); + } + static SPROUT_CONSTEXPR T signaling_NaN() SPROUT_NOEXCEPT { + return T(); + } + static SPROUT_CONSTEXPR T denorm_min() SPROUT_NOEXCEPT { + return T(); + } + }; + } // namespace detail + + template + class numeric_limits + : public sprout::detail::numeric_limits_impl::is_specialized> + {}; + template + class numeric_limits + : public sprout::numeric_limits + {}; + template + class numeric_limits + : public sprout::numeric_limits + {}; + template + class numeric_limits + : public sprout::numeric_limits + {}; + +#define SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL(TYPE, MIN, MAX) \ + template<> \ + class numeric_limits \ + : public sprout::detail::numeric_limits_base \ + { \ + public: \ + static SPROUT_CONSTEXPR TYPE min() SPROUT_NOEXCEPT { \ + return MIN; \ + } \ + static SPROUT_CONSTEXPR TYPE max() SPROUT_NOEXCEPT { \ + return MAX; \ + } \ + static SPROUT_CONSTEXPR TYPE lowest() SPROUT_NOEXCEPT { \ + return min(); \ + } \ + \ + static SPROUT_CONSTEXPR TYPE epsilon() SPROUT_NOEXCEPT { \ + return static_cast(0); \ + } \ + static SPROUT_CONSTEXPR TYPE round_error() SPROUT_NOEXCEPT { \ + return static_cast(0); \ + } \ + \ + static SPROUT_CONSTEXPR TYPE infinity() SPROUT_NOEXCEPT { \ + return static_cast(0); \ + } \ + static SPROUT_CONSTEXPR TYPE quiet_NaN() SPROUT_NOEXCEPT { \ + return static_cast(0); \ + } \ + static SPROUT_CONSTEXPR TYPE signaling_NaN() SPROUT_NOEXCEPT { \ + return static_cast(0); \ + } \ + static SPROUT_CONSTEXPR TYPE denorm_min() SPROUT_NOEXCEPT { \ + return static_cast(0); \ + } \ + } + + SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL(bool, false, true); + + SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL(short, SHRT_MIN, SHRT_MAX); + SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL(int, INT_MIN, INT_MAX); + SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL(long, LONG_MIN, LONG_MAX); + SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL(long long, LLONG_MIN, LLONG_MAX); + SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL(unsigned short, static_cast(0), USHRT_MAX); + SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL(unsigned int, static_cast(0), UINT_MAX); + SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL(unsigned long, static_cast(0), ULONG_MAX); + SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL(unsigned long long, static_cast(0), ULLONG_MAX); + + SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL(signed char, SCHAR_MIN, SCHAR_MAX); + SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL(unsigned char, static_cast(0), UCHAR_MAX); + SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL( + char16_t, + static_cast(sprout::numeric_limits::min()), + static_cast(sprout::numeric_limits::max()) + ); + SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL( + char32_t, + static_cast(sprout::numeric_limits::min()), + static_cast(sprout::numeric_limits::max()) + ); + SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL(wchar_t, WCHAR_MIN, WCHAR_MAX); +#undef SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL + +#define SPROUT_NUMERIC_LIMITS_FLOATING_POINT_SPECIALIZED_DECL(TYPE, MIN, MAX, EPS, RND, INF, QNAN, SNAN, DMIN) \ + template<> \ + class numeric_limits \ + : public sprout::detail::numeric_limits_base \ + { \ + public: \ + static SPROUT_CONSTEXPR TYPE min() SPROUT_NOEXCEPT { \ + return MIN; \ + } \ + static SPROUT_CONSTEXPR TYPE max() SPROUT_NOEXCEPT { \ + return MAX; \ + } \ + static SPROUT_CONSTEXPR TYPE lowest() SPROUT_NOEXCEPT { \ + return -max(); \ + } \ + \ + static SPROUT_CONSTEXPR TYPE epsilon() SPROUT_NOEXCEPT { \ + return EPS; \ + } \ + static SPROUT_CONSTEXPR TYPE round_error() SPROUT_NOEXCEPT { \ + return RND; \ + } \ + \ + static SPROUT_CONSTEXPR TYPE infinity() SPROUT_NOEXCEPT { \ + return INF; \ + } \ + static SPROUT_CONSTEXPR TYPE quiet_NaN() SPROUT_NOEXCEPT { \ + return QNAN; \ + } \ + static SPROUT_CONSTEXPR TYPE signaling_NaN() SPROUT_NOEXCEPT { \ + return SNAN; \ + } \ + static SPROUT_CONSTEXPR TYPE denorm_min() SPROUT_NOEXCEPT { \ + return DMIN; \ + } \ + } + + SPROUT_NUMERIC_LIMITS_FLOATING_POINT_SPECIALIZED_DECL( + float, + FLT_MIN, FLT_MAX, + FLT_EPSILON, 0.5F, + __builtin_huge_valf(), __builtin_nanf(""), __builtin_nansf(""), __FLT_DENORM_MIN__ + ); + SPROUT_NUMERIC_LIMITS_FLOATING_POINT_SPECIALIZED_DECL( + double, + DBL_MIN, DBL_MAX, + DBL_EPSILON, 0.5, + __builtin_huge_val(), __builtin_nan(""), __builtin_nans(""), __DBL_DENORM_MIN__ + ); + SPROUT_NUMERIC_LIMITS_FLOATING_POINT_SPECIALIZED_DECL( + long double, + LDBL_MIN, LDBL_MAX, + LDBL_EPSILON, 0.5L, + __builtin_huge_val(), __builtin_nan(""), __builtin_nans(""), __LDBL_DENORM_MIN__ + ); +#undef SPROUT_NUMERIC_LIMITS_FLOATING_POINT_SPECIALIZED_DECL + +#else // #ifdef SPROUT_NO_CXX11_NUMERIC_LIMITS + +#if SPROUT_USE_TEMPLATE_ALIASES + template + using numeric_limits = std::numeric_limits; +#else // #if SPROUT_USE_TEMPLATE_ALIASES + template + class numeric_limits + : public std::numeric_limits + {}; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES + +#endif // #ifdef SPROUT_NO_CXX11_NUMERIC_LIMITS +} // namespace sprout + +#endif // #ifndef SPROUT_LIMITS_HPP diff --git a/sprout/math/acos.hpp b/sprout/math/acos.hpp index 84cddb41..185c56d9 100644 --- a/sprout/math/acos.hpp +++ b/sprout/math/acos.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_ACOS_HPP #define SPROUT_MATH_ACOS_HPP -#include #include #include +#include #include #include #include @@ -28,7 +28,7 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType acos(FloatType x) { return sprout::math::isnan(x) ? x - : sprout::math::fabs(x) > 1 ? std::numeric_limits::quiet_NaN() + : sprout::math::fabs(x) > 1 ? sprout::numeric_limits::quiet_NaN() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::acos(x) #else diff --git a/sprout/math/acosh.hpp b/sprout/math/acosh.hpp index 0fb5f546..90848021 100644 --- a/sprout/math/acosh.hpp +++ b/sprout/math/acosh.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_ACOSH_HPP #define SPROUT_MATH_ACOSH_HPP -#include #include #include +#include #include #include #include @@ -27,8 +27,8 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType acosh(FloatType x) { return sprout::math::isnan(x) ? x - : x < 1 ? -std::numeric_limits::quiet_NaN() - : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() + : x < 1 ? -sprout::numeric_limits::quiet_NaN() + : x == sprout::numeric_limits::infinity() ? sprout::numeric_limits::infinity() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::acosh(x) #else diff --git a/sprout/math/asin.hpp b/sprout/math/asin.hpp index 4c3b585d..82ba4d79 100644 --- a/sprout/math/asin.hpp +++ b/sprout/math/asin.hpp @@ -2,9 +2,9 @@ #define SPROUT_MATH_ASIN_HPP #include -#include #include #include +#include #include #include #include @@ -77,7 +77,7 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType asin(FloatType x) { return sprout::math::isnan(x) ? x - : sprout::math::fabs(x) > 1 ? std::numeric_limits::quiet_NaN() + : sprout::math::fabs(x) > 1 ? sprout::numeric_limits::quiet_NaN() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::asin(x) #else diff --git a/sprout/math/asinh.hpp b/sprout/math/asinh.hpp index 673f4ffd..06e3d2b9 100644 --- a/sprout/math/asinh.hpp +++ b/sprout/math/asinh.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_ASINH_HPP #define SPROUT_MATH_ASINH_HPP -#include #include #include +#include #include #include #include @@ -27,8 +27,8 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType asinh(FloatType x) { return sprout::math::isnan(x) ? x - : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() - : x == -std::numeric_limits::infinity() ? -std::numeric_limits::infinity() + : x == sprout::numeric_limits::infinity() ? sprout::numeric_limits::infinity() + : x == -sprout::numeric_limits::infinity() ? -sprout::numeric_limits::infinity() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::asinh(x) #else diff --git a/sprout/math/atan.hpp b/sprout/math/atan.hpp index c68cf2f8..985142f6 100644 --- a/sprout/math/atan.hpp +++ b/sprout/math/atan.hpp @@ -2,9 +2,9 @@ #define SPROUT_MATH_ATAN_HPP #include -#include #include #include +#include #include #include #include @@ -43,8 +43,8 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType atan(FloatType x) { return sprout::math::isnan(x) ? x - : x == std::numeric_limits::infinity() ? sprout::math::half_pi() - : x == -std::numeric_limits::infinity() ? -sprout::math::half_pi() + : x == sprout::numeric_limits::infinity() ? sprout::math::half_pi() + : x == -sprout::numeric_limits::infinity() ? -sprout::math::half_pi() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::atan(x) #else diff --git a/sprout/math/atan2.hpp b/sprout/math/atan2.hpp index 791e8e8c..b7b68333 100644 --- a/sprout/math/atan2.hpp +++ b/sprout/math/atan2.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_ATAN2_HPP #define SPROUT_MATH_ATAN2_HPP -#include #include #include +#include #include #include #include @@ -37,20 +37,20 @@ namespace sprout { atan2(FloatType y, FloatType x) { return sprout::math::isnan(y) ? sprout::math::isnan(x) - ? sprout::math::signbit(y) && sprout::math::signbit(x) ? -std::numeric_limits::quiet_NaN() - : std::numeric_limits::quiet_NaN() + ? sprout::math::signbit(y) && sprout::math::signbit(x) ? -sprout::numeric_limits::quiet_NaN() + : sprout::numeric_limits::quiet_NaN() : y : sprout::math::isnan(x) ? x - : x == -std::numeric_limits::infinity() - ? y == std::numeric_limits::infinity() ? sprout::math::three_quarters_pi() - : y == -std::numeric_limits::infinity() ? -sprout::math::three_quarters_pi() + : x == -sprout::numeric_limits::infinity() + ? y == sprout::numeric_limits::infinity() ? sprout::math::three_quarters_pi() + : y == -sprout::numeric_limits::infinity() ? -sprout::math::three_quarters_pi() : sprout::math::copysign(sprout::math::pi(), y) - : x == std::numeric_limits::infinity() - ? y == std::numeric_limits::infinity() ? sprout::math::quarter_pi() - : y == -std::numeric_limits::infinity() ? -sprout::math::quarter_pi() + : x == sprout::numeric_limits::infinity() + ? y == sprout::numeric_limits::infinity() ? sprout::math::quarter_pi() + : y == -sprout::numeric_limits::infinity() ? -sprout::math::quarter_pi() : FloatType(0) * y - : y == std::numeric_limits::infinity() ? sprout::math::half_pi() - : y == -std::numeric_limits::infinity() ? -sprout::math::half_pi() + : y == sprout::numeric_limits::infinity() ? sprout::math::half_pi() + : y == -sprout::numeric_limits::infinity() ? -sprout::math::half_pi() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::atan2(y, x) #else diff --git a/sprout/math/atanh.hpp b/sprout/math/atanh.hpp index ad85ebfd..67339835 100644 --- a/sprout/math/atanh.hpp +++ b/sprout/math/atanh.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_ATANH_HPP #define SPROUT_MATH_ATANH_HPP -#include #include #include +#include #include #include #include @@ -27,9 +27,9 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType atanh(FloatType x) { return sprout::math::isnan(x) ? x - : x == 1 ? std::numeric_limits::infinity() - : x == -1 ? -std::numeric_limits::infinity() - : sprout::math::fabs(x) > 1 ? -std::numeric_limits::quiet_NaN() + : x == 1 ? sprout::numeric_limits::infinity() + : x == -1 ? -sprout::numeric_limits::infinity() + : sprout::math::fabs(x) > 1 ? -sprout::numeric_limits::quiet_NaN() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::atanh(x) #else diff --git a/sprout/math/cbrt.hpp b/sprout/math/cbrt.hpp index 8b89df68..a74a208c 100644 --- a/sprout/math/cbrt.hpp +++ b/sprout/math/cbrt.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_CBRT_HPP #define SPROUT_MATH_CBRT_HPP -#include #include #include +#include #include #include #include @@ -29,8 +29,8 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType cbrt(FloatType x) { return sprout::math::isnan(x) ? x - : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() - : x == -std::numeric_limits::infinity() ? -std::numeric_limits::infinity() + : x == sprout::numeric_limits::infinity() ? sprout::numeric_limits::infinity() + : x == -sprout::numeric_limits::infinity() ? -sprout::numeric_limits::infinity() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::cbrt(x) #else diff --git a/sprout/math/ceil.hpp b/sprout/math/ceil.hpp index bd231a90..de72459a 100644 --- a/sprout/math/ceil.hpp +++ b/sprout/math/ceil.hpp @@ -2,10 +2,10 @@ #define SPROUT_MATH_CEIL_HPP #include -#include #include #include #include +#include #include #include #include @@ -37,13 +37,13 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType ceil(FloatType x) { return sprout::math::isnan(x) ? x - : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() - : x == -std::numeric_limits::infinity() ? -std::numeric_limits::infinity() + : x == sprout::numeric_limits::infinity() ? sprout::numeric_limits::infinity() + : x == -sprout::numeric_limits::infinity() ? -sprout::numeric_limits::infinity() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::ceil(x) #else : x == 0 ? x - : std::numeric_limits::max() < x || std::numeric_limits::max() < -x + : sprout::numeric_limits::max() < x || sprout::numeric_limits::max() < -x ? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("ceil: large float rounding."), x) : static_cast(sprout::math::detail::ceil_impl(static_cast::type>(x))) #endif diff --git a/sprout/math/copysign.hpp b/sprout/math/copysign.hpp index 5df0a45a..4cf46a18 100644 --- a/sprout/math/copysign.hpp +++ b/sprout/math/copysign.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_COPYSIGN_HPP #define SPROUT_MATH_COPYSIGN_HPP -#include #include #include +#include #include #include #include @@ -25,8 +25,8 @@ namespace sprout { : FloatType(0) : sprout::math::isnan(x) ? sprout::math::isnan(y) ? y - : sprout::math::signbit(y) ? -std::numeric_limits::quiet_NaN() - : std::numeric_limits::quiet_NaN() + : sprout::math::signbit(y) ? -sprout::numeric_limits::quiet_NaN() + : sprout::numeric_limits::quiet_NaN() : sprout::math::signbit(y) != sprout::math::signbit(x) ? -x : x ; diff --git a/sprout/math/cos.hpp b/sprout/math/cos.hpp index 8e323200..6fdf44cf 100644 --- a/sprout/math/cos.hpp +++ b/sprout/math/cos.hpp @@ -2,9 +2,9 @@ #define SPROUT_MATH_COS_HPP #include -#include #include #include +#include #include #include #include @@ -38,6 +38,7 @@ namespace sprout { ); } + // !!! // template // inline SPROUT_CONSTEXPR T // cos_impl_2(T x) { @@ -70,8 +71,8 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType cos(FloatType x) { return sprout::math::isnan(x) ? x - : x == std::numeric_limits::infinity() || x == -std::numeric_limits::infinity() - ? -std::numeric_limits::quiet_NaN() + : x == sprout::numeric_limits::infinity() || x == -sprout::numeric_limits::infinity() + ? -sprout::numeric_limits::quiet_NaN() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::cos(x) #else diff --git a/sprout/math/cosh.hpp b/sprout/math/cosh.hpp index f91d0d32..23b15149 100644 --- a/sprout/math/cosh.hpp +++ b/sprout/math/cosh.hpp @@ -2,9 +2,9 @@ #define SPROUT_MATH_COSH_HPP #include -#include #include #include +#include #include #include #include @@ -32,8 +32,8 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType cosh(FloatType x) { return sprout::math::isnan(x) ? x - : x == std::numeric_limits::infinity() || x == -std::numeric_limits::infinity() - ? std::numeric_limits::infinity() + : x == sprout::numeric_limits::infinity() || x == -sprout::numeric_limits::infinity() + ? sprout::numeric_limits::infinity() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::cosh(x) #else diff --git a/sprout/math/equal_to.hpp b/sprout/math/equal_to.hpp index 2175aeae..1ff1c389 100644 --- a/sprout/math/equal_to.hpp +++ b/sprout/math/equal_to.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_EQUAL_TO_HPP #define SPROUT_MATH_EQUAL_TO_HPP -#include #include #include +#include #include #include #include @@ -23,7 +23,7 @@ namespace sprout { equal_to_impl(FloatType x, FloatType y) { return x == y || sprout::fabs(x - y) - <= std::numeric_limits::epsilon() * sprout::math::detail::max3(sprout::fabs(x), sprout::fabs(y), FloatType(1)) + <= sprout::numeric_limits::epsilon() * sprout::math::detail::max3(sprout::fabs(x), sprout::fabs(y), FloatType(1)) ; } diff --git a/sprout/math/erf.hpp b/sprout/math/erf.hpp index 477838e7..73a1794c 100644 --- a/sprout/math/erf.hpp +++ b/sprout/math/erf.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_ERF_HPP #define SPROUT_MATH_ERF_HPP -#include #include #include +#include #include #include #include @@ -126,8 +126,8 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType erf(FloatType x) { return sprout::math::isnan(x) ? x - : x == std::numeric_limits::infinity() ? FloatType(1) - : x == -std::numeric_limits::infinity() ? FloatType(-1) + : x == sprout::numeric_limits::infinity() ? FloatType(1) + : x == -sprout::numeric_limits::infinity() ? FloatType(-1) #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::erf(x) #else diff --git a/sprout/math/erfc.hpp b/sprout/math/erfc.hpp index 2cff9ace..01bf198f 100644 --- a/sprout/math/erfc.hpp +++ b/sprout/math/erfc.hpp @@ -25,8 +25,8 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType erfc(FloatType x) { return sprout::math::isnan(x) ? x - : x == std::numeric_limits::infinity() ? FloatType(0) - : x == -std::numeric_limits::infinity() ? FloatType(2) + : x == sprout::numeric_limits::infinity() ? FloatType(0) + : x == -sprout::numeric_limits::infinity() ? FloatType(2) #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::erfc(x) #else diff --git a/sprout/math/exp.hpp b/sprout/math/exp.hpp index c01aa614..712c0e5e 100644 --- a/sprout/math/exp.hpp +++ b/sprout/math/exp.hpp @@ -2,9 +2,9 @@ #define SPROUT_MATH_EXP_HPP #include -#include #include #include +#include #include #include #include @@ -39,8 +39,8 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType exp(FloatType x) { return sprout::math::isnan(x) ? x - : x == -std::numeric_limits::infinity() ? FloatType(0) - : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() + : x == -sprout::numeric_limits::infinity() ? FloatType(0) + : x == sprout::numeric_limits::infinity() ? sprout::numeric_limits::infinity() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::exp(x) #else diff --git a/sprout/math/exp10.hpp b/sprout/math/exp10.hpp index ddfbc8b1..884fc3e0 100644 --- a/sprout/math/exp10.hpp +++ b/sprout/math/exp10.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_EXP10_HPP #define SPROUT_MATH_EXP10_HPP -#include #include #include +#include #include #include #include @@ -27,8 +27,8 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType exp10(FloatType x) { return sprout::math::isnan(x) ? x - : x == -std::numeric_limits::infinity() ? FloatType(0) - : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() + : x == -sprout::numeric_limits::infinity() ? FloatType(0) + : x == sprout::numeric_limits::infinity() ? sprout::numeric_limits::infinity() : x == 0 ? FloatType(1) : static_cast(sprout::math::detail::exp10_impl(static_cast::type>(x))) ; diff --git a/sprout/math/exp2.hpp b/sprout/math/exp2.hpp index 9b88e002..fb59a152 100644 --- a/sprout/math/exp2.hpp +++ b/sprout/math/exp2.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_EXP2_HPP #define SPROUT_MATH_EXP2_HPP -#include #include #include +#include #include #include #include @@ -27,8 +27,8 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType exp2(FloatType x) { return sprout::math::isnan(x) ? x - : x == -std::numeric_limits::infinity() ? FloatType(0) - : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() + : x == -sprout::numeric_limits::infinity() ? FloatType(0) + : x == sprout::numeric_limits::infinity() ? sprout::numeric_limits::infinity() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::exp2(x) #else diff --git a/sprout/math/expm1.hpp b/sprout/math/expm1.hpp index 6e4cef0f..c30916d3 100644 --- a/sprout/math/expm1.hpp +++ b/sprout/math/expm1.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_EXPM1_HPP #define SPROUT_MATH_EXPM1_HPP -#include #include #include +#include #include #include #include @@ -28,8 +28,8 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType expm1(FloatType x) { return sprout::math::isnan(x) ? x - : x == -std::numeric_limits::infinity() ? FloatType(-1) - : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() + : x == -sprout::numeric_limits::infinity() ? FloatType(-1) + : x == sprout::numeric_limits::infinity() ? sprout::numeric_limits::infinity() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::expm1(x) #else diff --git a/sprout/math/fabs.hpp b/sprout/math/fabs.hpp index c40ba71b..00c9c191 100644 --- a/sprout/math/fabs.hpp +++ b/sprout/math/fabs.hpp @@ -17,7 +17,7 @@ namespace sprout { > inline SPROUT_CONSTEXPR FloatType fabs(FloatType x) { - return sprout::math::isnan(x) ? std::numeric_limits::quiet_NaN() + return sprout::math::isnan(x) ? sprout::numeric_limits::quiet_NaN() : x == 0 ? FloatType(0) : sprout::math::copysign(x, FloatType(0)) ; diff --git a/sprout/math/fdim.hpp b/sprout/math/fdim.hpp index a991fb89..b571d9cd 100644 --- a/sprout/math/fdim.hpp +++ b/sprout/math/fdim.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_FDIM_HPP #define SPROUT_MATH_FDIM_HPP -#include #include #include +#include #include #include #include @@ -20,10 +20,10 @@ namespace sprout { fdim(FloatType x, FloatType y) { return sprout::math::isnan(y) ? y : sprout::math::isnan(x) ? x - : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() - : x == -std::numeric_limits::infinity() ? FloatType(0) - : y == std::numeric_limits::infinity() ? FloatType(0) - : y == -std::numeric_limits::infinity() ? std::numeric_limits::infinity() + : x == sprout::numeric_limits::infinity() ? sprout::numeric_limits::infinity() + : x == -sprout::numeric_limits::infinity() ? FloatType(0) + : y == sprout::numeric_limits::infinity() ? FloatType(0) + : y == -sprout::numeric_limits::infinity() ? sprout::numeric_limits::infinity() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::fdim(x, y) #else diff --git a/sprout/math/float2_exponent.hpp b/sprout/math/float2_exponent.hpp index 493830df..8c310f67 100644 --- a/sprout/math/float2_exponent.hpp +++ b/sprout/math/float2_exponent.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_FLOAT2_EXPONENT_HPP #define SPROUT_MATH_FLOAT2_EXPONENT_HPP -#include #include #include +#include #include #include #include @@ -20,7 +20,7 @@ namespace sprout { float2_exponent(FloatType x) { return sprout::math::isnan(x) ? 0 : x == 0 ? 0 - : x == std::numeric_limits::infinity() || x == -std::numeric_limits::infinity() ? 0 + : x == sprout::numeric_limits::infinity() || x == -sprout::numeric_limits::infinity() ? 0 : sprout::math::ilogb2(x) + 1 ; } diff --git a/sprout/math/float2_sig_exp.hpp b/sprout/math/float2_sig_exp.hpp index bf011377..eef72c9e 100644 --- a/sprout/math/float2_sig_exp.hpp +++ b/sprout/math/float2_sig_exp.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_FLOAT2_SIG_EXP_HPP #define SPROUT_MATH_FLOAT2_SIG_EXP_HPP -#include #include #include +#include #include #include #include @@ -29,8 +29,8 @@ namespace sprout { float2_sig_exp(FloatType x) { typedef sprout::pair type; return sprout::math::isnan(x) ? type(x, 0) - : x == std::numeric_limits::infinity() ? type(std::numeric_limits::infinity(), 0) - : x == -std::numeric_limits::infinity() ? type(-std::numeric_limits::infinity(), 0) + : x == sprout::numeric_limits::infinity() ? type(sprout::numeric_limits::infinity(), 0) + : x == -sprout::numeric_limits::infinity() ? type(-sprout::numeric_limits::infinity(), 0) : x == 0 ? type(x, 0) : sprout::math::detail::float2_sig_exp_impl(x, sprout::math::ilogb2(x) + 1) ; diff --git a/sprout/math/float2_significand.hpp b/sprout/math/float2_significand.hpp index c812a93c..2ff897d4 100644 --- a/sprout/math/float2_significand.hpp +++ b/sprout/math/float2_significand.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_FLOAT2_SIGNIFICAND_HPP #define SPROUT_MATH_FLOAT2_SIGNIFICAND_HPP -#include #include #include +#include #include #include #include @@ -20,8 +20,8 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType float2_significand(FloatType x) { return sprout::math::isnan(x) ? x - : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() - : x == -std::numeric_limits::infinity() ? -std::numeric_limits::infinity() + : x == sprout::numeric_limits::infinity() ? sprout::numeric_limits::infinity() + : x == -sprout::numeric_limits::infinity() ? -sprout::numeric_limits::infinity() : x == 0 ? x : x / sprout::detail::pow_n(FloatType(2), sprout::float2_exponent(x)) ; diff --git a/sprout/math/float_exponent.hpp b/sprout/math/float_exponent.hpp index ee90bf35..e22eba71 100644 --- a/sprout/math/float_exponent.hpp +++ b/sprout/math/float_exponent.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_FLOAT_EXPONENT_HPP #define SPROUT_MATH_FLOAT_EXPONENT_HPP -#include #include #include +#include #include #include #include @@ -20,7 +20,7 @@ namespace sprout { float_exponent(FloatType x) { return sprout::math::isnan(x) ? 0 : x == 0 ? 0 - : x == std::numeric_limits::infinity() || x == -std::numeric_limits::infinity() ? 0 + : x == sprout::numeric_limits::infinity() || x == -sprout::numeric_limits::infinity() ? 0 : sprout::math::ilogb(x) + 1 ; } diff --git a/sprout/math/float_sig_exp.hpp b/sprout/math/float_sig_exp.hpp index a4238613..c1338bf8 100644 --- a/sprout/math/float_sig_exp.hpp +++ b/sprout/math/float_sig_exp.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_FLOAT_SIG_EXP_HPP #define SPROUT_MATH_FLOAT_SIG_EXP_HPP -#include #include #include +#include #include #include #include @@ -18,7 +18,7 @@ namespace sprout { inline SPROUT_CONSTEXPR sprout::pair float_sig_exp_impl(T x, int exp) { typedef sprout::pair type; - return type(x / sprout::detail::pow_n(T(std::numeric_limits::radix), exp), exp); + return type(x / sprout::detail::pow_n(T(sprout::numeric_limits::radix), exp), exp); } template< @@ -29,8 +29,8 @@ namespace sprout { float_sig_exp(FloatType x) { typedef sprout::pair type; return sprout::math::isnan(x) ? type(x, 0) - : x == std::numeric_limits::infinity() ? type(std::numeric_limits::infinity(), 0) - : x == -std::numeric_limits::infinity() ? type(-std::numeric_limits::infinity(), 0) + : x == sprout::numeric_limits::infinity() ? type(sprout::numeric_limits::infinity(), 0) + : x == -sprout::numeric_limits::infinity() ? type(-sprout::numeric_limits::infinity(), 0) : x == 0 ? type(x, 0) : sprout::math::detail::float_sig_exp_impl(x, sprout::math::ilogb(x) + 1) ; diff --git a/sprout/math/float_significand.hpp b/sprout/math/float_significand.hpp index 7beaadad..ebcc0e65 100644 --- a/sprout/math/float_significand.hpp +++ b/sprout/math/float_significand.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_FLOAT_SIGNIFICAND_HPP #define SPROUT_MATH_FLOAT_SIGNIFICAND_HPP -#include #include #include +#include #include #include #include @@ -20,10 +20,10 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType float_significand(FloatType x) { return sprout::math::isnan(x) ? x - : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() - : x == -std::numeric_limits::infinity() ? -std::numeric_limits::infinity() + : x == sprout::numeric_limits::infinity() ? sprout::numeric_limits::infinity() + : x == -sprout::numeric_limits::infinity() ? -sprout::numeric_limits::infinity() : x == 0 ? x - : x / sprout::detail::pow_n(FloatType(std::numeric_limits::radix), sprout::float_exponent(x)) + : x / sprout::detail::pow_n(FloatType(sprout::numeric_limits::radix), sprout::float_exponent(x)) ; } template< diff --git a/sprout/math/floor.hpp b/sprout/math/floor.hpp index 970acec4..c685af81 100644 --- a/sprout/math/floor.hpp +++ b/sprout/math/floor.hpp @@ -2,10 +2,10 @@ #define SPROUT_MATH_FLOOR_HPP #include -#include #include #include #include +#include #include #include #include @@ -37,13 +37,13 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType floor(FloatType x) { return sprout::math::isnan(x) ? x - : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() - : x == -std::numeric_limits::infinity() ? -std::numeric_limits::infinity() + : x == sprout::numeric_limits::infinity() ? sprout::numeric_limits::infinity() + : x == -sprout::numeric_limits::infinity() ? -sprout::numeric_limits::infinity() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::floor(x) #else : x == 0 ? x - : std::numeric_limits::max() < x || std::numeric_limits::max() < -x + : sprout::numeric_limits::max() < x || sprout::numeric_limits::max() < -x ? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("floor: large float rounding."), x) : static_cast(sprout::math::detail::floor_impl(static_cast::type>(x))) #endif diff --git a/sprout/math/fma.hpp b/sprout/math/fma.hpp index a936925e..e8757df6 100644 --- a/sprout/math/fma.hpp +++ b/sprout/math/fma.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_FMA_HPP #define SPROUT_MATH_FMA_HPP -#include #include #include +#include #include #include #include @@ -23,10 +23,10 @@ namespace sprout { return sprout::math::isnan(x) ? x : sprout::math::isnan(y) ? y : sprout::math::isnan(z) ? z - : sprout::math::isinf(x) && y == 0 ? std::numeric_limits::quiet_NaN() - : sprout::math::isinf(y) && x == 0 ? std::numeric_limits::quiet_NaN() + : sprout::math::isinf(x) && y == 0 ? sprout::numeric_limits::quiet_NaN() + : sprout::math::isinf(y) && x == 0 ? sprout::numeric_limits::quiet_NaN() : (sprout::math::isinf(x) || sprout::math::isinf(y)) && sprout::math::isinf(z) && (sprout::math::signbit(x) ^ sprout::math::signbit(y) ^ sprout::math::signbit(z)) - ? std::numeric_limits::quiet_NaN() + ? sprout::numeric_limits::quiet_NaN() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::fma(x, y, z) #else diff --git a/sprout/math/fmax.hpp b/sprout/math/fmax.hpp index 854ea112..da74b38b 100644 --- a/sprout/math/fmax.hpp +++ b/sprout/math/fmax.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_FMAX_HPP #define SPROUT_MATH_FMAX_HPP -#include #include #include +#include #include #include #include @@ -20,10 +20,10 @@ namespace sprout { fmax(FloatType x, FloatType y) { return sprout::math::isnan(y) ? x : sprout::math::isnan(x) ? y - : y == -std::numeric_limits::infinity() ? x - : x == std::numeric_limits::infinity() ? x - : x == -std::numeric_limits::infinity() ? y - : y == std::numeric_limits::infinity() ? y + : y == -sprout::numeric_limits::infinity() ? x + : x == sprout::numeric_limits::infinity() ? x + : x == -sprout::numeric_limits::infinity() ? y + : y == sprout::numeric_limits::infinity() ? y #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : x == 0 && y == 0 ? x : std::fmax(x, y) diff --git a/sprout/math/fmin.hpp b/sprout/math/fmin.hpp index 8cee7a82..bd800d02 100644 --- a/sprout/math/fmin.hpp +++ b/sprout/math/fmin.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_FMIN_HPP #define SPROUT_MATH_FMIN_HPP -#include #include #include +#include #include #include #include @@ -20,10 +20,10 @@ namespace sprout { fmin(FloatType x, FloatType y) { return sprout::math::isnan(y) ? x : sprout::math::isnan(x) ? y - : x == -std::numeric_limits::infinity() ? x - : y == std::numeric_limits::infinity() ? x - : y == -std::numeric_limits::infinity() ? y - : x == std::numeric_limits::infinity() ? y + : x == -sprout::numeric_limits::infinity() ? x + : y == sprout::numeric_limits::infinity() ? x + : y == -sprout::numeric_limits::infinity() ? y + : x == sprout::numeric_limits::infinity() ? y #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : x == 0 && y == 0 ? x : std::fmin(x, y) diff --git a/sprout/math/fmod.hpp b/sprout/math/fmod.hpp index 9d3de506..f7894b6e 100644 --- a/sprout/math/fmod.hpp +++ b/sprout/math/fmod.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_FMOD_HPP #define SPROUT_MATH_FMOD_HPP -#include #include #include +#include #include #include #include @@ -73,14 +73,14 @@ namespace sprout { fmod(FloatType x, FloatType y) { return sprout::math::isnan(y) ? sprout::math::isnan(x) - ? sprout::math::signbit(y) || sprout::math::signbit(x) ? -std::numeric_limits::quiet_NaN() - : std::numeric_limits::quiet_NaN() + ? sprout::math::signbit(y) || sprout::math::signbit(x) ? -sprout::numeric_limits::quiet_NaN() + : sprout::numeric_limits::quiet_NaN() : y : sprout::math::isnan(x) ? x - : x == std::numeric_limits::infinity() || x == -std::numeric_limits::infinity() || y == 0 - ? -std::numeric_limits::quiet_NaN() + : x == sprout::numeric_limits::infinity() || x == -sprout::numeric_limits::infinity() || y == 0 + ? -sprout::numeric_limits::quiet_NaN() : x == 0 ? x - : y == std::numeric_limits::infinity() || y == -std::numeric_limits::infinity() ? x + : y == sprout::numeric_limits::infinity() || y == -sprout::numeric_limits::infinity() ? x : static_cast(sprout::math::detail::fmod_impl( static_cast::type>(x), static_cast::type>(y) diff --git a/sprout/math/frac_int.hpp b/sprout/math/frac_int.hpp index bb1f4f3a..3428e6a9 100644 --- a/sprout/math/frac_int.hpp +++ b/sprout/math/frac_int.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_FRAC_INT_HPP #define SPROUT_MATH_FRAC_INT_HPP -#include #include #include +#include #include #include #include @@ -19,7 +19,7 @@ namespace sprout { frac_int_impl(T x, T ipart) { typedef sprout::pair type; return sprout::math::isnan(x) ? type(x, ipart) - : x == std::numeric_limits::infinity() || x == -std::numeric_limits::infinity() ? type(sprout::math::copysign(T(0), x), ipart) + : x == sprout::numeric_limits::infinity() || x == -sprout::numeric_limits::infinity() ? type(sprout::math::copysign(T(0), x), ipart) : x == 0 ? type(x, ipart) : x == ipart ? type(T(0) * x, ipart) : type(sprout::math::copysign(x - ipart, x), ipart) diff --git a/sprout/math/fractional_part.hpp b/sprout/math/fractional_part.hpp index 6084ea55..baffd52f 100644 --- a/sprout/math/fractional_part.hpp +++ b/sprout/math/fractional_part.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_FRACTIONAL_PART_HPP #define SPROUT_MATH_FRACTIONAL_PART_HPP -#include #include #include +#include #include #include #include @@ -28,7 +28,7 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType fractional_part(FloatType x) { return sprout::math::isnan(x) ? x - : x == std::numeric_limits::infinity() || x == -std::numeric_limits::infinity() ? sprout::math::copysign(FloatType(0), x) + : x == sprout::numeric_limits::infinity() || x == -sprout::numeric_limits::infinity() ? sprout::math::copysign(FloatType(0), x) : x == 0 ? x : sprout::math::detail::fractional_part_impl(x, sprout::integer_part(x)) ; diff --git a/sprout/math/gcd.hpp b/sprout/math/gcd.hpp index 3789ebfa..12dfdc94 100644 --- a/sprout/math/gcd.hpp +++ b/sprout/math/gcd.hpp @@ -2,8 +2,8 @@ #define SPROUT_MATH_GCD_HPP #include -#include #include +#include #include #include #ifdef SPROUT_WORKAROUND_NOT_TERMINATE_RECURSIVE_CONSTEXPR_FUNCTION_TEMPLATE @@ -158,7 +158,7 @@ namespace sprout { struct gcd_optimal_evaluator { public: SPROUT_CONSTEXPR T operator()(T const& a, T const& b) const { - typedef std::numeric_limits limits_type; + typedef sprout::numeric_limits limits_type; typedef sprout::math::detail::gcd_optimal_evaluator_helper_t< T, limits_type::is_specialized, limits_type::is_signed > helper_type; diff --git a/sprout/math/hypot.hpp b/sprout/math/hypot.hpp index 62320e9e..886fc0d2 100644 --- a/sprout/math/hypot.hpp +++ b/sprout/math/hypot.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_HYPOT_HPP #define SPROUT_MATH_HYPOT_HPP -#include #include #include +#include #include #include #include @@ -41,10 +41,10 @@ namespace sprout { > inline SPROUT_CONSTEXPR FloatType hypot(FloatType x, FloatType y) { - return y == std::numeric_limits::infinity() || y == -std::numeric_limits::infinity() - ? std::numeric_limits::infinity() - : x == std::numeric_limits::infinity() || x == -std::numeric_limits::infinity() - ? std::numeric_limits::infinity() + return y == sprout::numeric_limits::infinity() || y == -sprout::numeric_limits::infinity() + ? sprout::numeric_limits::infinity() + : x == sprout::numeric_limits::infinity() || x == -sprout::numeric_limits::infinity() + ? sprout::numeric_limits::infinity() : sprout::math::isnan(y) ? y : sprout::math::isnan(x) ? x #if SPROUT_USE_BUILTIN_CMATH_FUNCTION diff --git a/sprout/math/iceil.hpp b/sprout/math/iceil.hpp index 22385f76..15ac87a9 100644 --- a/sprout/math/iceil.hpp +++ b/sprout/math/iceil.hpp @@ -1,10 +1,10 @@ #ifndef SPROUT_MATH_ICEIL_HPP #define SPROUT_MATH_ICEIL_HPP -#include #include #include #include +#include #include #include #include @@ -22,7 +22,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR To iceil_impl(FloatType x) { - return std::numeric_limits::max() < x || std::numeric_limits::min() > x + return sprout::numeric_limits::max() < x || sprout::numeric_limits::min() > x ? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("iceil: large float rounding."), static_cast(x)) : static_cast(x) ; @@ -34,7 +34,7 @@ namespace sprout { > inline SPROUT_CONSTEXPR To iceil(FloatType x) { - return sprout::math::isnan(x) || sprout::math::isinf(x) ? std::numeric_limits::min() + return sprout::math::isnan(x) || sprout::math::isinf(x) ? sprout::numeric_limits::min() : sprout::math::detail::iceil_impl(sprout::math::ceil(x)) ; } @@ -53,9 +53,9 @@ namespace sprout { > inline SPROUT_CONSTEXPR To iceil(FloatType x) { - return sprout::math::isnan(x) || sprout::math::isinf(x) ? std::numeric_limits::min() + return sprout::math::isnan(x) || sprout::math::isinf(x) ? sprout::numeric_limits::min() : x == 0 ? To(0) - : std::numeric_limits::max() < x || std::numeric_limits::min() > x + : sprout::numeric_limits::max() < x || sprout::numeric_limits::min() > x ? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("iceil: large float rounding."), static_cast(x)) : sprout::math::detail::iceil_impl(x, static_cast(x)) ; diff --git a/sprout/math/ifloor.hpp b/sprout/math/ifloor.hpp index 0b470168..00e09b8d 100644 --- a/sprout/math/ifloor.hpp +++ b/sprout/math/ifloor.hpp @@ -1,10 +1,10 @@ #ifndef SPROUT_MATH_IFLOOR_HPP #define SPROUT_MATH_IFLOOR_HPP -#include #include #include #include +#include #include #include #include @@ -22,7 +22,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR To ifloor_impl(FloatType x) { - return std::numeric_limits::max() < x || std::numeric_limits::min() > x + return sprout::numeric_limits::max() < x || sprout::numeric_limits::min() > x ? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("ifloor: large float rounding."), static_cast(x)) : static_cast(x) ; @@ -34,7 +34,7 @@ namespace sprout { > inline SPROUT_CONSTEXPR To ifloor(FloatType x) { - return sprout::math::isnan(x) || sprout::math::isinf(x) ? std::numeric_limits::min() + return sprout::math::isnan(x) || sprout::math::isinf(x) ? sprout::numeric_limits::min() : sprout::math::detail::ifloor_impl(sprout::math::floor(x)) ; } @@ -53,9 +53,9 @@ namespace sprout { > inline SPROUT_CONSTEXPR To ifloor(FloatType x) { - return sprout::math::isnan(x) || sprout::math::isinf(x) ? std::numeric_limits::min() + return sprout::math::isnan(x) || sprout::math::isinf(x) ? sprout::numeric_limits::min() : x == 0 ? To(0) - : std::numeric_limits::max() < x || std::numeric_limits::min() > x + : sprout::numeric_limits::max() < x || sprout::numeric_limits::min() > x ? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("ifloor: large float rounding."), static_cast(x)) : sprout::math::detail::ifloor_impl(x, static_cast(x)) ; diff --git a/sprout/math/integer_part.hpp b/sprout/math/integer_part.hpp index 794bee53..96e130d7 100644 --- a/sprout/math/integer_part.hpp +++ b/sprout/math/integer_part.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_INTEGER_PART_HPP #define SPROUT_MATH_INTEGER_PART_HPP -#include #include #include +#include #include #include #include @@ -19,8 +19,8 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType integer_part(FloatType x) { return sprout::math::isnan(x) ? x - : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() - : x == -std::numeric_limits::infinity() ? -std::numeric_limits::infinity() + : x == sprout::numeric_limits::infinity() ? sprout::numeric_limits::infinity() + : x == -sprout::numeric_limits::infinity() ? -sprout::numeric_limits::infinity() : x == 0 ? x : sprout::math::trunc(x) ; diff --git a/sprout/math/iround.hpp b/sprout/math/iround.hpp index e769f92b..9668b711 100644 --- a/sprout/math/iround.hpp +++ b/sprout/math/iround.hpp @@ -1,10 +1,10 @@ #ifndef SPROUT_MATH_IROUND_HPP #define SPROUT_MATH_IROUND_HPP -#include #include #include #include +#include #include #include #include @@ -22,7 +22,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR To iround_impl(FloatType x) { - return std::numeric_limits::max() < x || std::numeric_limits::min() > x + return sprout::numeric_limits::max() < x || sprout::numeric_limits::min() > x ? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("iround: large float rounding."), static_cast(x)) : static_cast(x) ; @@ -34,7 +34,7 @@ namespace sprout { > inline SPROUT_CONSTEXPR To iround(FloatType x) { - return sprout::math::isnan(x) || sprout::math::isinf(x) ? std::numeric_limits::min() + return sprout::math::isnan(x) || sprout::math::isinf(x) ? sprout::numeric_limits::min() : sprout::math::detail::iround_impl(sprout::math::round(x)) ; } @@ -60,9 +60,9 @@ namespace sprout { > inline SPROUT_CONSTEXPR To iround(FloatType x) { - return sprout::math::isnan(x) || sprout::math::isinf(x) ? std::numeric_limits::min() + return sprout::math::isnan(x) || sprout::math::isinf(x) ? sprout::numeric_limits::min() : x == 0 ? To(0) - : std::numeric_limits::max() < x || std::numeric_limits::min() > x + : sprout::numeric_limits::max() < x || sprout::numeric_limits::min() > x ? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("iround: large float irounding."), x) : x < 0 ? sprout::math::detail::iround_impl_nagative(x, static_cast(x)) : sprout::math::detail::iround_impl_positive(x, static_cast(x)) diff --git a/sprout/math/isinf.hpp b/sprout/math/isinf.hpp index 81db067a..76fe19d7 100644 --- a/sprout/math/isinf.hpp +++ b/sprout/math/isinf.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_ISINF_HPP #define SPROUT_MATH_ISINF_HPP -#include #include #include +#include #include #include @@ -16,8 +16,8 @@ namespace sprout { > inline SPROUT_CONSTEXPR bool isinf(FloatType x) { - return x == std::numeric_limits::infinity() - || x == -std::numeric_limits::infinity() + return x == sprout::numeric_limits::infinity() + || x == -sprout::numeric_limits::infinity() ; } } // namespace detail diff --git a/sprout/math/issubnormal.hpp b/sprout/math/issubnormal.hpp index c1cd0d16..807c2ca7 100644 --- a/sprout/math/issubnormal.hpp +++ b/sprout/math/issubnormal.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_ISSUBNORMAL_HPP #define SPROUT_MATH_ISSUBNORMAL_HPP -#include #include #include +#include #include #include #include @@ -18,8 +18,8 @@ namespace sprout { inline SPROUT_CONSTEXPR bool issubnormal_or_zero(FloatType x) { return x > 0 - ? x < std::numeric_limits::min() - : x > -std::numeric_limits::min() + ? x < sprout::numeric_limits::min() + : x > -sprout::numeric_limits::min() ; } diff --git a/sprout/math/itrunc.hpp b/sprout/math/itrunc.hpp index c4077fa8..493c8b5a 100644 --- a/sprout/math/itrunc.hpp +++ b/sprout/math/itrunc.hpp @@ -1,10 +1,10 @@ #ifndef SPROUT_MATH_ITRUNC_HPP #define SPROUT_MATH_ITRUNC_HPP -#include #include #include #include +#include #include #include #include @@ -20,7 +20,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR To itrunc_impl(FloatType x) { - return std::numeric_limits::max() < x || std::numeric_limits::min() > x + return sprout::numeric_limits::max() < x || sprout::numeric_limits::min() > x ? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("itrunc: large float rounding."), static_cast(x)) : static_cast(x) ; @@ -32,7 +32,7 @@ namespace sprout { > inline SPROUT_CONSTEXPR To itrunc(FloatType x) { - return sprout::math::isnan(x) || sprout::math::isinf(x) ? std::numeric_limits::min() + return sprout::math::isnan(x) || sprout::math::isinf(x) ? sprout::numeric_limits::min() : sprout::math::detail::itrunc_impl(sprout::math::trunc(x)) ; } @@ -44,9 +44,9 @@ namespace sprout { > inline SPROUT_CONSTEXPR To itrunc(FloatType x) { - return sprout::math::isnan(x) || sprout::math::isinf(x) ? std::numeric_limits::min() + return sprout::math::isnan(x) || sprout::math::isinf(x) ? sprout::numeric_limits::min() : x == 0 ? To(0) - : std::numeric_limits::max() < x || std::numeric_limits::min() > x + : sprout::numeric_limits::max() < x || sprout::numeric_limits::min() > x ? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("itrunc: large float rounding."), static_cast(x)) : static_cast(x) ; diff --git a/sprout/math/lcm.hpp b/sprout/math/lcm.hpp index f4d323fb..8eec4847 100644 --- a/sprout/math/lcm.hpp +++ b/sprout/math/lcm.hpp @@ -2,8 +2,8 @@ #define SPROUT_MATH_LCM_HPP #include -#include #include +#include #include namespace sprout { @@ -56,7 +56,7 @@ namespace sprout { struct lcm_optimal_evaluator { public: SPROUT_CONSTEXPR T operator()(T const& a, T const& b) const { - typedef std::numeric_limits limits_type; + typedef sprout::numeric_limits limits_type; typedef sprout::math::detail::lcm_optimal_evaluator_helper_t< T, limits_type::is_specialized, limits_type::is_signed > helper_type; diff --git a/sprout/math/ldexp.hpp b/sprout/math/ldexp.hpp index f1390108..afa01e3e 100644 --- a/sprout/math/ldexp.hpp +++ b/sprout/math/ldexp.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_LDEXP_HPP #define SPROUT_MATH_LDEXP_HPP -#include #include #include +#include #include #include #include @@ -26,8 +26,8 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType ldexp(FloatType x, int exp) { return sprout::math::isnan(x) ? x - : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() - : x == -std::numeric_limits::infinity() ? -std::numeric_limits::infinity() + : x == sprout::numeric_limits::infinity() ? sprout::numeric_limits::infinity() + : x == -sprout::numeric_limits::infinity() ? -sprout::numeric_limits::infinity() : exp == 0 ? x : x == 0 ? x : static_cast(sprout::math::detail::ldexp_impl(static_cast::type>(x), exp)) diff --git a/sprout/math/lgamma.hpp b/sprout/math/lgamma.hpp index 21db5246..a20684e1 100644 --- a/sprout/math/lgamma.hpp +++ b/sprout/math/lgamma.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_LGAMMA_HPP #define SPROUT_MATH_LGAMMA_HPP -#include #include #include +#include #include #include #include @@ -184,9 +184,9 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType lgamma(FloatType x) { return sprout::math::isnan(x) ? x - : x <= 0 && sprout::math::is_integer(x) ? std::numeric_limits::infinity() - : x == -std::numeric_limits::infinity() ? std::numeric_limits::infinity() - : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() + : x <= 0 && sprout::math::is_integer(x) ? sprout::numeric_limits::infinity() + : x == -sprout::numeric_limits::infinity() ? sprout::numeric_limits::infinity() + : x == sprout::numeric_limits::infinity() ? sprout::numeric_limits::infinity() //#if SPROUT_USE_BUILTIN_CMATH_FUNCTION // : std::lgamma(x) //#else diff --git a/sprout/math/llround.hpp b/sprout/math/llround.hpp index bef42ac7..04805b13 100644 --- a/sprout/math/llround.hpp +++ b/sprout/math/llround.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_LLROUND_HPP #define SPROUT_MATH_LLROUND_HPP -#include #include #include +#include #include #include #include @@ -19,7 +19,7 @@ namespace sprout { > inline SPROUT_CONSTEXPR long long llround(FloatType x) { - return sprout::math::isnan(x) || sprout::math::isinf(x) ? std::numeric_limits::min() + return sprout::math::isnan(x) || sprout::math::isinf(x) ? sprout::numeric_limits::min() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::llround(x) #else diff --git a/sprout/math/log.hpp b/sprout/math/log.hpp index ddd7d899..e5e2c77c 100644 --- a/sprout/math/log.hpp +++ b/sprout/math/log.hpp @@ -2,9 +2,9 @@ #define SPROUT_MATH_LOG_HPP #include -#include #include #include +#include #include #include #include @@ -49,9 +49,9 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType log(FloatType x) { return sprout::math::isnan(x) ? x - : x == 0 ? -std::numeric_limits::infinity() - : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() - : x < 0 ? std::numeric_limits::quiet_NaN() + : x == 0 ? -sprout::numeric_limits::infinity() + : x == sprout::numeric_limits::infinity() ? sprout::numeric_limits::infinity() + : x < 0 ? sprout::numeric_limits::quiet_NaN() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::log(x) #else diff --git a/sprout/math/log10.hpp b/sprout/math/log10.hpp index 236f00f4..718d3494 100644 --- a/sprout/math/log10.hpp +++ b/sprout/math/log10.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_LOG10_HPP #define SPROUT_MATH_LOG10_HPP -#include #include #include +#include #include #include #include @@ -27,9 +27,9 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType log10(FloatType x) { return sprout::math::isnan(x) ? x - : x == 0 ? -std::numeric_limits::infinity() - : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() - : x < 0 ? std::numeric_limits::quiet_NaN() + : x == 0 ? -sprout::numeric_limits::infinity() + : x == sprout::numeric_limits::infinity() ? sprout::numeric_limits::infinity() + : x < 0 ? sprout::numeric_limits::quiet_NaN() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::log10(x) #else diff --git a/sprout/math/log1p.hpp b/sprout/math/log1p.hpp index 9a00908b..a6985a87 100644 --- a/sprout/math/log1p.hpp +++ b/sprout/math/log1p.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_LOG1P_HPP #define SPROUT_MATH_LOG1P_HPP -#include #include #include +#include #include #include #include @@ -26,9 +26,9 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType log1p(FloatType x) { return sprout::math::isnan(x) ? x - : x == -1 ? -std::numeric_limits::infinity() - : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() - : x < -1 ? -std::numeric_limits::quiet_NaN() + : x == -1 ? -sprout::numeric_limits::infinity() + : x == sprout::numeric_limits::infinity() ? sprout::numeric_limits::infinity() + : x < -1 ? -sprout::numeric_limits::quiet_NaN() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::log1p(x) #else diff --git a/sprout/math/log2.hpp b/sprout/math/log2.hpp index b7fdeafd..a49a8183 100644 --- a/sprout/math/log2.hpp +++ b/sprout/math/log2.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_LOG2_HPP #define SPROUT_MATH_LOG2_HPP -#include #include #include +#include #include #include #include @@ -27,9 +27,9 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType log2(FloatType x) { return sprout::math::isnan(x) ? x - : x == 0 ? -std::numeric_limits::infinity() - : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() - : x < 0 ? std::numeric_limits::quiet_NaN() + : x == 0 ? -sprout::numeric_limits::infinity() + : x == sprout::numeric_limits::infinity() ? sprout::numeric_limits::infinity() + : x < 0 ? sprout::numeric_limits::quiet_NaN() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::log2(x) #else diff --git a/sprout/math/logb.hpp b/sprout/math/logb.hpp index 0b70c0f4..ac349ca7 100644 --- a/sprout/math/logb.hpp +++ b/sprout/math/logb.hpp @@ -2,9 +2,9 @@ #define SPROUT_MATH_LOGB_HPP #include -#include #include #include +#include #include #include #include @@ -22,7 +22,7 @@ namespace sprout { inline SPROUT_CONSTEXPR T logb_impl_3_neg_lo(T x, T x0, T base, T exp) { return base < 1 ? sprout::math::detail::logb_impl_3_neg_lo( - x, x0 * std::numeric_limits::radix, x / (x0 / std::numeric_limits::radix), exp - 1 + x, x0 * sprout::numeric_limits::radix, x / (x0 / sprout::numeric_limits::radix), exp - 1 ) : exp ; @@ -30,8 +30,8 @@ namespace sprout { template inline SPROUT_CONSTEXPR T logb_impl_3_neg_hi(T x, T x0, T base, T exp) { - return !(base < std::numeric_limits::radix) ? sprout::math::detail::logb_impl_3_neg_hi( - x, x0 / std::numeric_limits::radix, x / (x0 * std::numeric_limits::radix), exp + 1 + return !(base < sprout::numeric_limits::radix) ? sprout::math::detail::logb_impl_3_neg_hi( + x, x0 / sprout::numeric_limits::radix, x / (x0 * sprout::numeric_limits::radix), exp + 1 ) : exp ; @@ -40,7 +40,7 @@ namespace sprout { inline SPROUT_CONSTEXPR T logb_impl_3_pos_lo(T x, T x0, T base, T exp) { return base < 1 ? sprout::math::detail::logb_impl_3_pos_lo( - x, x0 * std::numeric_limits::radix, x / (x0 / std::numeric_limits::radix), exp - 1 + x, x0 * sprout::numeric_limits::radix, x / (x0 / sprout::numeric_limits::radix), exp - 1 ) : exp ; @@ -48,8 +48,8 @@ namespace sprout { template inline SPROUT_CONSTEXPR T logb_impl_3_pos_hi(T x, T x0, T base, T exp) { - return !(base < std::numeric_limits::radix) ? sprout::math::detail::logb_impl_3_pos_hi( - x, x0 / std::numeric_limits::radix, x / (x0 * std::numeric_limits::radix), exp + 1 + return !(base < sprout::numeric_limits::radix) ? sprout::math::detail::logb_impl_3_pos_hi( + x, x0 / sprout::numeric_limits::radix, x / (x0 * sprout::numeric_limits::radix), exp + 1 ) : exp ; @@ -59,17 +59,17 @@ namespace sprout { logb_impl_3(T x, T x0, T base, T exp) { return x < 1 ? base < 1 ? sprout::math::detail::logb_impl_3_neg_lo( - x, x0 * std::numeric_limits::radix, x / (x0 / std::numeric_limits::radix), exp - 1 + x, x0 * sprout::numeric_limits::radix, x / (x0 / sprout::numeric_limits::radix), exp - 1 ) - : !(base < std::numeric_limits::radix) ? sprout::math::detail::logb_impl_3_neg_hi( - x, x0 / std::numeric_limits::radix, x / (x0 * std::numeric_limits::radix), exp + 1 + : !(base < sprout::numeric_limits::radix) ? sprout::math::detail::logb_impl_3_neg_hi( + x, x0 / sprout::numeric_limits::radix, x / (x0 * sprout::numeric_limits::radix), exp + 1 ) : exp : base < 1 ? sprout::math::detail::logb_impl_3_pos_lo( - x, x0 * std::numeric_limits::radix, x / (x0 / std::numeric_limits::radix), exp - 1 + x, x0 * sprout::numeric_limits::radix, x / (x0 / sprout::numeric_limits::radix), exp - 1 ) - : !(base < std::numeric_limits::radix) ? sprout::math::detail::logb_impl_3_pos_hi( - x, x0 / std::numeric_limits::radix, x / (x0 * std::numeric_limits::radix), exp + 1 + : !(base < sprout::numeric_limits::radix) ? sprout::math::detail::logb_impl_3_pos_hi( + x, x0 / sprout::numeric_limits::radix, x / (x0 * sprout::numeric_limits::radix), exp + 1 ) : exp ; @@ -83,14 +83,14 @@ namespace sprout { inline SPROUT_CONSTEXPR T logb_impl_1(T x, T exp) { return sprout::math::detail::logb_impl_2( - x, sprout::detail::pow_n(T(std::numeric_limits::radix), sprout::math::itrunc(exp)), exp + x, sprout::detail::pow_n(T(sprout::numeric_limits::radix), sprout::math::itrunc(exp)), exp ); } template inline SPROUT_CONSTEXPR T logb_impl(T x) { - return x < 0 ? sprout::math::detail::logb_impl_1(-x, sprout::math::trunc(sprout::math::log_a(T(std::numeric_limits::radix), -x))) - : sprout::math::detail::logb_impl_1(x, sprout::math::trunc(sprout::math::log_a(T(std::numeric_limits::radix), x))) + return x < 0 ? sprout::math::detail::logb_impl_1(-x, sprout::math::trunc(sprout::math::log_a(T(sprout::numeric_limits::radix), -x))) + : sprout::math::detail::logb_impl_1(x, sprout::math::trunc(sprout::math::log_a(T(sprout::numeric_limits::radix), x))) ; } @@ -101,16 +101,16 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType logb(FloatType x) { return sprout::math::isnan(x) ? x - : x == 0 ? -std::numeric_limits::infinity() + : x == 0 ? -sprout::numeric_limits::infinity() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION # if defined(__GNUC__) - : x == -std::numeric_limits::infinity() - ? std::numeric_limits::infinity() + : x == -sprout::numeric_limits::infinity() + ? sprout::numeric_limits::infinity() # endif : std::logb(x) #else - : x == std::numeric_limits::infinity() || x == -std::numeric_limits::infinity() - ? std::numeric_limits::infinity() + : x == sprout::numeric_limits::infinity() || x == -sprout::numeric_limits::infinity() + ? sprout::numeric_limits::infinity() : static_cast(sprout::math::detail::logb_impl(static_cast::type>(x))) #endif ; diff --git a/sprout/math/logb2.hpp b/sprout/math/logb2.hpp index f49ca33d..1ba5c9a5 100644 --- a/sprout/math/logb2.hpp +++ b/sprout/math/logb2.hpp @@ -10,7 +10,7 @@ # include #else # include -# include +# include # include # include # include @@ -123,9 +123,9 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType logb2(FloatType x) { return sprout::math::isnan(x) ? x - : x == 0 ? -std::numeric_limits::infinity() - : x == std::numeric_limits::infinity() || x == -std::numeric_limits::infinity() - ? std::numeric_limits::infinity() + : x == 0 ? -sprout::numeric_limits::infinity() + : x == sprout::numeric_limits::infinity() || x == -sprout::numeric_limits::infinity() + ? sprout::numeric_limits::infinity() : static_cast(sprout::math::detail::logb2_impl(static_cast::type>(x))) ; } diff --git a/sprout/math/lround.hpp b/sprout/math/lround.hpp index 71a21e37..f60ebaeb 100644 --- a/sprout/math/lround.hpp +++ b/sprout/math/lround.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_LROUND_HPP #define SPROUT_MATH_LROUND_HPP -#include #include #include +#include #include #include #include @@ -19,7 +19,7 @@ namespace sprout { > inline SPROUT_CONSTEXPR long lround(FloatType x) { - return sprout::math::isnan(x) || sprout::math::isinf(x) ? std::numeric_limits::min() + return sprout::math::isnan(x) || sprout::math::isinf(x) ? sprout::numeric_limits::min() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::lround(x) #else diff --git a/sprout/math/pow.hpp b/sprout/math/pow.hpp index 26b1feca..fbcee0fe 100644 --- a/sprout/math/pow.hpp +++ b/sprout/math/pow.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_POW_HPP #define SPROUT_MATH_POW_HPP -#include #include #include +#include #include #include #include @@ -37,27 +37,27 @@ namespace sprout { : sprout::math::isnan(x) ? x : x == 0 ? y < 0 - ? sprout::math::is_odd(y) ? sprout::math::copysign(std::numeric_limits::infinity(), x) - : std::numeric_limits::infinity() + ? sprout::math::is_odd(y) ? sprout::math::copysign(sprout::numeric_limits::infinity(), x) + : sprout::numeric_limits::infinity() : sprout::math::is_odd(y) ? x : FloatType(0) - : x == -1 && (y == std::numeric_limits::infinity() || y == -std::numeric_limits::infinity()) ? FloatType(1) - : y == -std::numeric_limits::infinity() - ? sprout::math::fabs(x) < 1 ? std::numeric_limits::infinity() + : x == -1 && (y == sprout::numeric_limits::infinity() || y == -sprout::numeric_limits::infinity()) ? FloatType(1) + : y == -sprout::numeric_limits::infinity() + ? sprout::math::fabs(x) < 1 ? sprout::numeric_limits::infinity() : FloatType(0) - : y == std::numeric_limits::infinity() + : y == sprout::numeric_limits::infinity() ? sprout::math::fabs(x) < 1 ? FloatType(0) - : std::numeric_limits::infinity() - : x == -std::numeric_limits::infinity() + : sprout::numeric_limits::infinity() + : x == -sprout::numeric_limits::infinity() ? y < 0 ? sprout::math::is_odd(y) ? -FloatType(0) : FloatType(0) - : sprout::math::is_odd(y) ? -std::numeric_limits::infinity() - : std::numeric_limits::infinity() - : x == std::numeric_limits::infinity() + : sprout::math::is_odd(y) ? -sprout::numeric_limits::infinity() + : sprout::numeric_limits::infinity() + : x == sprout::numeric_limits::infinity() ? y < 0 ? FloatType(0) - : std::numeric_limits::infinity() - : x < 0 && !sprout::math::is_integer(y) ? std::numeric_limits::quiet_NaN() + : sprout::numeric_limits::infinity() + : x < 0 && !sprout::math::is_integer(y) ? sprout::numeric_limits::quiet_NaN() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::pow(x, y) #else diff --git a/sprout/math/quotient.hpp b/sprout/math/quotient.hpp index 1a1b1287..7be890cc 100644 --- a/sprout/math/quotient.hpp +++ b/sprout/math/quotient.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_QUOTIENT_HPP #define SPROUT_MATH_QUOTIENT_HPP -#include #include #include +#include #include #include #include @@ -23,10 +23,10 @@ namespace sprout { quotient(FloatType x, FloatType y) { return y == 0 ? R(0) : sprout::math::isnan(y) || sprout::math::isnan(x) ? R(0) - : x == std::numeric_limits::infinity() || x == -std::numeric_limits::infinity() + : x == sprout::numeric_limits::infinity() || x == -sprout::numeric_limits::infinity() ? R(0) : x == 0 ? R(0) - : y == std::numeric_limits::infinity() || y == -std::numeric_limits::infinity() ? R(0) + : y == sprout::numeric_limits::infinity() || y == -sprout::numeric_limits::infinity() ? R(0) : sprout::math::rem_quo(x, y).second ; } diff --git a/sprout/math/rem_quo.hpp b/sprout/math/rem_quo.hpp index 5a983027..26977d24 100644 --- a/sprout/math/rem_quo.hpp +++ b/sprout/math/rem_quo.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_REM_QUO_HPP #define SPROUT_MATH_REM_QUO_HPP -#include #include #include +#include #include #include #include @@ -89,16 +89,16 @@ namespace sprout { inline SPROUT_CONSTEXPR sprout::pair rem_quo(FloatType x, FloatType y) { typedef sprout::pair type; - return y == 0 ? type(-std::numeric_limits::quiet_NaN(), R(0)) + return y == 0 ? type(-sprout::numeric_limits::quiet_NaN(), R(0)) : sprout::math::isnan(y) ? sprout::math::isnan(x) - ? type(sprout::math::signbit(y) && sprout::math::signbit(x) ? -std::numeric_limits::quiet_NaN() : std::numeric_limits::quiet_NaN(), R(0)) + ? type(sprout::math::signbit(y) && sprout::math::signbit(x) ? -sprout::numeric_limits::quiet_NaN() : sprout::numeric_limits::quiet_NaN(), R(0)) : type(y, R(0)) : sprout::math::isnan(x) ? type(x, R(0)) - : x == std::numeric_limits::infinity() || x == -std::numeric_limits::infinity() - ? type(-std::numeric_limits::quiet_NaN(), R(0)) + : x == sprout::numeric_limits::infinity() || x == -sprout::numeric_limits::infinity() + ? type(-sprout::numeric_limits::quiet_NaN(), R(0)) : x == 0 ? type(x, R(0)) - : y == std::numeric_limits::infinity() || y == -std::numeric_limits::infinity() ? type(x, R(0)) + : y == sprout::numeric_limits::infinity() || y == -sprout::numeric_limits::infinity() ? type(x, R(0)) : sprout::math::detail::rem_quo_ret(sprout::math::detail::rem_quo_impl( static_cast::type>(x), static_cast::type>(y), diff --git a/sprout/math/remainder.hpp b/sprout/math/remainder.hpp index 9455f3d3..eea84055 100644 --- a/sprout/math/remainder.hpp +++ b/sprout/math/remainder.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_REMAINDER_HPP #define SPROUT_MATH_REMAINDER_HPP -#include #include #include +#include #include #include #include @@ -20,17 +20,17 @@ namespace sprout { > inline SPROUT_CONSTEXPR FloatType remainder(FloatType x, FloatType y) { - return y == 0 ? -std::numeric_limits::quiet_NaN() + return y == 0 ? -sprout::numeric_limits::quiet_NaN() : sprout::math::isnan(y) ? sprout::math::isnan(x) - ? sprout::math::signbit(y) && sprout::math::signbit(x) ? -std::numeric_limits::quiet_NaN() - : std::numeric_limits::quiet_NaN() + ? sprout::math::signbit(y) && sprout::math::signbit(x) ? -sprout::numeric_limits::quiet_NaN() + : sprout::numeric_limits::quiet_NaN() : y : sprout::math::isnan(x) ? x - : x == std::numeric_limits::infinity() || x == -std::numeric_limits::infinity() - ? -std::numeric_limits::quiet_NaN() + : x == sprout::numeric_limits::infinity() || x == -sprout::numeric_limits::infinity() + ? -sprout::numeric_limits::quiet_NaN() : x == 0 ? x - : y == std::numeric_limits::infinity() || y == -std::numeric_limits::infinity() ? x + : y == sprout::numeric_limits::infinity() || y == -sprout::numeric_limits::infinity() ? x #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::remainder(x, y) #else diff --git a/sprout/math/round.hpp b/sprout/math/round.hpp index 83367bd5..94a25a0d 100644 --- a/sprout/math/round.hpp +++ b/sprout/math/round.hpp @@ -2,10 +2,10 @@ #define SPROUT_MATH_ROUND_HPP #include -#include #include #include #include +#include #include #include #include @@ -43,13 +43,13 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType round(FloatType x) { return sprout::math::isnan(x) ? x - : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() - : x == -std::numeric_limits::infinity() ? -std::numeric_limits::infinity() + : x == sprout::numeric_limits::infinity() ? sprout::numeric_limits::infinity() + : x == -sprout::numeric_limits::infinity() ? -sprout::numeric_limits::infinity() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::round(x) #else : x == 0 ? x - : std::numeric_limits::max() < x || std::numeric_limits::max() < -x + : sprout::numeric_limits::max() < x || sprout::numeric_limits::max() < -x ? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("round: large float rounding."), x) : static_cast(sprout::math::detail::round_impl(static_cast::type>(x))) #endif diff --git a/sprout/math/scalbln.hpp b/sprout/math/scalbln.hpp index ff20c640..46516dc9 100644 --- a/sprout/math/scalbln.hpp +++ b/sprout/math/scalbln.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_SCALBLN_HPP #define SPROUT_MATH_SCALBLN_HPP -#include #include #include +#include #include #include #include @@ -16,7 +16,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR T scalbln_impl(T x, long exp) { - return x * sprout::detail::pow_n(T(std::numeric_limits::radix), exp); + return x * sprout::detail::pow_n(T(sprout::numeric_limits::radix), exp); } template< @@ -26,8 +26,8 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType scalbln(FloatType x, long exp) { return sprout::math::isnan(x) ? x - : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() - : x == -std::numeric_limits::infinity() ? -std::numeric_limits::infinity() + : x == sprout::numeric_limits::infinity() ? sprout::numeric_limits::infinity() + : x == -sprout::numeric_limits::infinity() ? -sprout::numeric_limits::infinity() : exp == 0 ? x : x == 0 ? x : static_cast(sprout::math::detail::scalbln_impl(static_cast::type>(x), exp)) diff --git a/sprout/math/scalbn.hpp b/sprout/math/scalbn.hpp index 256cf892..e0f8964e 100644 --- a/sprout/math/scalbn.hpp +++ b/sprout/math/scalbn.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_SCALBN_HPP #define SPROUT_MATH_SCALBN_HPP -#include #include #include +#include #include #include #include @@ -16,7 +16,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR T scalbn_impl(T x, int exp) { - return x * sprout::detail::pow_n(T(std::numeric_limits::radix), exp); + return x * sprout::detail::pow_n(T(sprout::numeric_limits::radix), exp); } template< @@ -26,8 +26,8 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType scalbn(FloatType x, int exp) { return sprout::math::isnan(x) ? x - : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() - : x == -std::numeric_limits::infinity() ? -std::numeric_limits::infinity() + : x == sprout::numeric_limits::infinity() ? sprout::numeric_limits::infinity() + : x == -sprout::numeric_limits::infinity() ? -sprout::numeric_limits::infinity() : exp == 0 ? x : x == 0 ? x : static_cast(sprout::math::detail::scalbn_impl(static_cast::type>(x), exp)) diff --git a/sprout/math/sin.hpp b/sprout/math/sin.hpp index e65ae171..4c7a411f 100644 --- a/sprout/math/sin.hpp +++ b/sprout/math/sin.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_SIN_HPP #define SPROUT_MATH_SIN_HPP -#include #include #include +#include #include #include #include @@ -27,8 +27,8 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType sin(FloatType x) { return sprout::math::isnan(x) ? x - : x == std::numeric_limits::infinity() || x == -std::numeric_limits::infinity() - ? -std::numeric_limits::quiet_NaN() + : x == sprout::numeric_limits::infinity() || x == -sprout::numeric_limits::infinity() + ? -sprout::numeric_limits::quiet_NaN() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::sin(x) #else diff --git a/sprout/math/sinh.hpp b/sprout/math/sinh.hpp index 82ec686d..b267faf5 100644 --- a/sprout/math/sinh.hpp +++ b/sprout/math/sinh.hpp @@ -2,9 +2,9 @@ #define SPROUT_MATH_SINH_HPP #include -#include #include #include +#include #include #include #include @@ -32,8 +32,8 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType sinh(FloatType x) { return sprout::math::isnan(x) ? x - : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() - : x == -std::numeric_limits::infinity() ? -std::numeric_limits::infinity() + : x == sprout::numeric_limits::infinity() ? sprout::numeric_limits::infinity() + : x == -sprout::numeric_limits::infinity() ? -sprout::numeric_limits::infinity() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::sinh(x) #else diff --git a/sprout/math/sqrt.hpp b/sprout/math/sqrt.hpp index 09031931..2c07c3a9 100644 --- a/sprout/math/sqrt.hpp +++ b/sprout/math/sqrt.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_SQRT_HPP #define SPROUT_MATH_SQRT_HPP -#include #include #include +#include #include #include #include @@ -37,8 +37,8 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType sqrt(FloatType x) { return sprout::math::isnan(x) ? x - : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() - : x < 0 ? -std::numeric_limits::quiet_NaN() + : x == sprout::numeric_limits::infinity() ? sprout::numeric_limits::infinity() + : x < 0 ? -sprout::numeric_limits::quiet_NaN() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::sqrt(x) #else diff --git a/sprout/math/tan.hpp b/sprout/math/tan.hpp index a95432e2..83d143fa 100644 --- a/sprout/math/tan.hpp +++ b/sprout/math/tan.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_TAN_HPP #define SPROUT_MATH_TAN_HPP -#include #include #include +#include #include #include #include @@ -27,8 +27,8 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType tan(FloatType x) { return sprout::math::isnan(x) ? x - : x == std::numeric_limits::infinity() || x == -std::numeric_limits::infinity() - ? -std::numeric_limits::quiet_NaN() + : x == sprout::numeric_limits::infinity() || x == -sprout::numeric_limits::infinity() + ? -sprout::numeric_limits::quiet_NaN() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::tan(x) #else diff --git a/sprout/math/tanh.hpp b/sprout/math/tanh.hpp index 1c2725df..bedbf30d 100644 --- a/sprout/math/tanh.hpp +++ b/sprout/math/tanh.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_MATH_TANH_HPP #define SPROUT_MATH_TANH_HPP -#include #include #include +#include #include #include #include @@ -36,8 +36,8 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType tanh(FloatType x) { return sprout::math::isnan(x) ? x - : x == std::numeric_limits::infinity() ? FloatType(1) - : x == -std::numeric_limits::infinity() ? FloatType(-1) + : x == sprout::numeric_limits::infinity() ? FloatType(1) + : x == -sprout::numeric_limits::infinity() ? FloatType(-1) #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::tanh(x) #else diff --git a/sprout/math/tgamma.hpp b/sprout/math/tgamma.hpp index c2f45f48..f6b5f837 100644 --- a/sprout/math/tgamma.hpp +++ b/sprout/math/tgamma.hpp @@ -2,9 +2,9 @@ #define SPROUT_MATH_TGAMMA_HPP #include -#include #include #include +#include #include #include #include @@ -71,7 +71,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR T tgamma_impl_2_pos_rec(T x, T y, T t) { - return t == 0 ? std::numeric_limits::infinity() + return t == 0 ? sprout::numeric_limits::infinity() : (x - T(1)) / y / t ; } @@ -108,10 +108,10 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType tgamma(FloatType x) { return sprout::math::isnan(x) ? x - : x == 0 ? sprout::math::copysign(std::numeric_limits::infinity(), x) - : x == -std::numeric_limits::infinity() ? -std::numeric_limits::quiet_NaN() - : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() - : x < 0 && sprout::math::is_integer(x) ? std::numeric_limits::quiet_NaN() + : x == 0 ? sprout::math::copysign(sprout::numeric_limits::infinity(), x) + : x == -sprout::numeric_limits::infinity() ? -sprout::numeric_limits::quiet_NaN() + : x == sprout::numeric_limits::infinity() ? sprout::numeric_limits::infinity() + : x < 0 && sprout::math::is_integer(x) ? sprout::numeric_limits::quiet_NaN() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::tgamma(x) #else diff --git a/sprout/math/trunc.hpp b/sprout/math/trunc.hpp index 92c7aa7d..ed026b07 100644 --- a/sprout/math/trunc.hpp +++ b/sprout/math/trunc.hpp @@ -2,10 +2,10 @@ #define SPROUT_MATH_TRUNC_HPP #include -#include #include #include #include +#include #include #include #include @@ -20,13 +20,13 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType trunc(FloatType x) { return sprout::math::isnan(x) ? x - : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() - : x == -std::numeric_limits::infinity() ? -std::numeric_limits::infinity() + : x == sprout::numeric_limits::infinity() ? sprout::numeric_limits::infinity() + : x == -sprout::numeric_limits::infinity() ? -sprout::numeric_limits::infinity() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::trunc(x) #else : x == 0 ? x - : std::numeric_limits::max() < x || std::numeric_limits::max() < -x + : sprout::numeric_limits::max() < x || sprout::numeric_limits::max() < -x ? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("trunc: large float rounding."), x) : x < 0 ? -static_cast(static_cast(-x)) : static_cast(static_cast(x)) diff --git a/sprout/random/detail/const_mod.hpp b/sprout/random/detail/const_mod.hpp index eb2a1536..565fb2cb 100644 --- a/sprout/random/detail/const_mod.hpp +++ b/sprout/random/detail/const_mod.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_RANDOM_DETAIL_CONST_MOD_HPP #define SPROUT_RANDOM_DETAIL_CONST_MOD_HPP -#include #include #include +#include #include #ifdef SPROUT_WORKAROUND_NOT_TERMINATE_RECURSIVE_CONSTEXPR_FUNCTION_TEMPLATE # include @@ -41,7 +41,7 @@ namespace sprout { return mult_schrage_1(a, value, m / a, m % a); } static SPROUT_CONSTEXPR IntType mult_general(IntType a, IntType b) { - return std::uintmax_t(modulus) <= std::numeric_limits::max() / modulus + return std::uintmax_t(modulus) <= sprout::numeric_limits::max() / modulus ? static_cast(std::uintmax_t(a) * b % modulus) //: static_cast(sprout::random::detail::mulmod(a, b, modulus)) // ??? : (SPROUT_ASSERT_MSG(0, "Sorry, not implemented."), IntType()) @@ -51,7 +51,7 @@ namespace sprout { return a < b ? m - (b - a) : a - b; } static SPROUT_CONSTEXPR unsigned_type unsigned_m() { - return m == 0 ? unsigned_type((std::numeric_limits::max)()) + 1 : unsigned_type(m); + return m == 0 ? unsigned_type((sprout::numeric_limits::max)()) + 1 : unsigned_type(m); } #ifdef SPROUT_WORKAROUND_NOT_TERMINATE_RECURSIVE_CONSTEXPR_FUNCTION_TEMPLATE template @@ -106,10 +106,10 @@ namespace sprout { } template static SPROUT_CONSTEXPR IntType invert_euclidian0_1(IntType c, IntType l1, IntType l2, IntType n) { - return SPROUT_ASSERT_MSG(std::numeric_limits::max() % n != n - 1, "c must be relatively prime to m."), + return SPROUT_ASSERT_MSG(sprout::numeric_limits::max() % n != n - 1, "c must be relatively prime to m."), invert_euclidian0_2( - c, l1 + (std::numeric_limits::max() / n) * l2, l2, n, - std::numeric_limits::max() - (std::numeric_limits::max() / n) * n + 1 + c, l1 + (sprout::numeric_limits::max() / n) * l2, l2, n, + sprout::numeric_limits::max() - (sprout::numeric_limits::max() / n) * n + 1 ) ; } @@ -149,10 +149,10 @@ namespace sprout { return p == 0 ? l2 : invert_euclidian0_3(c, l1, l2 + (n / p) * l1, n - (n / p) * p, p); } static SPROUT_CONSTEXPR IntType invert_euclidian0_1(IntType c, IntType l1, IntType l2, IntType n) { - return SPROUT_ASSERT_MSG(std::numeric_limits::max() % n != n - 1, "c must be relatively prime to m."), + return SPROUT_ASSERT_MSG(sprout::numeric_limits::max() % n != n - 1, "c must be relatively prime to m."), invert_euclidian0_2( - c, l1 + (std::numeric_limits::max() / n) * l2, l2, n, - std::numeric_limits::max() - (std::numeric_limits::max() / n) * n + 1 + c, l1 + (sprout::numeric_limits::max() / n) * l2, l2, n, + sprout::numeric_limits::max() - (sprout::numeric_limits::max() / n) * n + 1 ) ; } @@ -180,15 +180,15 @@ namespace sprout { return ((unsigned_m() - 1) & unsigned_m()) == 0 ? unsigned_type(a) * unsigned_type(x) & (unsigned_m() - 1) : a == 0 ? 0 : a == 1 ? x - : m <= std::numeric_limits::max() / a ? mult_small(a, x) - : std::numeric_limits::is_signed && (m % a < m / a) ? mult_schrage(a, x) + : m <= sprout::numeric_limits::max() / a ? mult_small(a, x) + : sprout::numeric_limits::is_signed && (m % a < m / a) ? mult_schrage(a, x) : mult_general(a, x) ; } static SPROUT_CONSTEXPR IntType mult_add(IntType a, IntType x, IntType c) { return ((unsigned_m() - 1) & unsigned_m()) == 0 ? (unsigned_type(a) * unsigned_type(x) + unsigned_type(c)) & (unsigned_m() - 1) : a == 0 ? c - : m <= (std::numeric_limits::max() - c) / a ? (a * x + c) % (m + supress_warnings) + : m <= (sprout::numeric_limits::max() - c) / a ? (a * x + c) % (m + supress_warnings) : add(mult(a, x), c) ; } diff --git a/sprout/random/detail/generator_bits.hpp b/sprout/random/detail/generator_bits.hpp index 4edfe93b..da7088fc 100644 --- a/sprout/random/detail/generator_bits.hpp +++ b/sprout/random/detail/generator_bits.hpp @@ -2,8 +2,8 @@ #define SPROUT_RANDOM_DETAIL_GENERATOR_BITS_HPP #include -#include #include +#include namespace sprout { namespace random { @@ -12,7 +12,7 @@ namespace sprout { struct generator_bits { public: static SPROUT_CONSTEXPR std::size_t value() { - return std::numeric_limits::digits; + return sprout::numeric_limits::digits; } }; } // namespace detail diff --git a/sprout/random/detail/signed_unsigned_tools.hpp b/sprout/random/detail/signed_unsigned_tools.hpp index 4785772b..13b27b1d 100644 --- a/sprout/random/detail/signed_unsigned_tools.hpp +++ b/sprout/random/detail/signed_unsigned_tools.hpp @@ -1,14 +1,14 @@ #ifndef SPROUT_RANDOM_DETAIL_SIGNED_UNSIGNED_TOOLS_HPP #define SPROUT_RANDOM_DETAIL_SIGNED_UNSIGNED_TOOLS_HPP -#include #include #include +#include namespace sprout { namespace random { namespace detail { - template::is_signed> + template::is_signed> struct subtract {}; template struct subtract { @@ -32,7 +32,7 @@ namespace sprout { } }; - template::is_signed> + template::is_signed> struct add {}; template struct add { diff --git a/sprout/random/detail/uniform_int_float.hpp b/sprout/random/detail/uniform_int_float.hpp index 77dd893e..c1325d97 100644 --- a/sprout/random/detail/uniform_int_float.hpp +++ b/sprout/random/detail/uniform_int_float.hpp @@ -3,8 +3,8 @@ #include #include -#include #include +#include #include #include #include @@ -19,9 +19,9 @@ namespace sprout { typedef URNG base_type; typedef typename base_type::result_type base_result; typedef typename sprout::detail::uint_t< - (std::numeric_limits::digits < std::numeric_limits::digits) - ? std::numeric_limits::digits - : std::numeric_limits::digits + (sprout::numeric_limits::digits < sprout::numeric_limits::digits) + ? sprout::numeric_limits::digits + : sprout::numeric_limits::digits >::fast result_type; private: base_type rng_; @@ -39,7 +39,7 @@ namespace sprout { return ( result_type(2) << ( NS_SSCRISK_CEL_OR_SPROUT::min( - std::numeric_limits::digits, + sprout::numeric_limits::digits, sprout::random::detail::generator_bits::value() ) - 1 ) diff --git a/sprout/random/geometric_distribution.hpp b/sprout/random/geometric_distribution.hpp index 560bd88a..5665813f 100644 --- a/sprout/random/geometric_distribution.hpp +++ b/sprout/random/geometric_distribution.hpp @@ -2,8 +2,8 @@ #define SPROUT_RANDOM_GEOMETRIC_DISTRIBUTION_HPP #include -#include #include +#include #include #include #include @@ -112,7 +112,7 @@ namespace sprout { return 0; } SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT { - return std::numeric_limits::max(); + return sprout::numeric_limits::max(); } SPROUT_CONSTEXPR param_type param() const SPROUT_NOEXCEPT { return param_type(p_); diff --git a/sprout/random/inversive_congruential.hpp b/sprout/random/inversive_congruential.hpp index 7bee173f..2e11ab85 100644 --- a/sprout/random/inversive_congruential.hpp +++ b/sprout/random/inversive_congruential.hpp @@ -2,10 +2,10 @@ #define SPROUT_RANDOM_INVERSIVE_CONGRUENTIAL_HPP #include -#include #include #include #include +#include #include #include #include diff --git a/sprout/random/linear_congruential.hpp b/sprout/random/linear_congruential.hpp index ff84dce5..225d296e 100644 --- a/sprout/random/linear_congruential.hpp +++ b/sprout/random/linear_congruential.hpp @@ -2,10 +2,10 @@ #define SPROUT_RANDOM_LINEAR_CONGRUENTIAL_HPP #include -#include #include #include #include +#include #include #include #include @@ -18,7 +18,7 @@ namespace sprout { // template class linear_congruential_engine { - static_assert(std::numeric_limits::is_integer, "std::numeric_limits::is_integer"); + static_assert(sprout::numeric_limits::is_integer, "sprout::numeric_limits::is_integer"); static_assert(m == 0 || a < m, "m == 0 || a < m"); static_assert(m == 0 || c < m, "m == 0 || c < m"); public: diff --git a/sprout/random/normal_distribution.hpp b/sprout/random/normal_distribution.hpp index 996d2622..03df1792 100644 --- a/sprout/random/normal_distribution.hpp +++ b/sprout/random/normal_distribution.hpp @@ -1,10 +1,10 @@ #ifndef SPROUT_RANDOM_NORMAL_DISTRIBUTION_HPP #define SPROUT_RANDOM_NORMAL_DISTRIBUTION_HPP -#include #include #include #include +#include #include #include #include @@ -185,10 +185,10 @@ namespace sprout { return sigma_; } SPROUT_CONSTEXPR result_type min() const SPROUT_NOEXCEPT { - return -std::numeric_limits::infinity(); + return -sprout::numeric_limits::infinity(); } SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT { - return std::numeric_limits::infinity(); + return sprout::numeric_limits::infinity(); } SPROUT_CONSTEXPR param_type param() const SPROUT_NOEXCEPT { return param_type(mean_, sigma_); diff --git a/sprout/random/shuffle_order.hpp b/sprout/random/shuffle_order.hpp index 412b4ec2..6694ff80 100644 --- a/sprout/random/shuffle_order.hpp +++ b/sprout/random/shuffle_order.hpp @@ -3,11 +3,11 @@ #include #include -#include #include #include #include #include +#include #include #include #include @@ -38,8 +38,8 @@ namespace sprout { : private sprout::random::detail::shuffle_order_engine_member { static_assert( - std::numeric_limits::is_integer, - "std::numeric_limits::is_integer" + sprout::numeric_limits::is_integer, + "sprout::numeric_limits::is_integer" ); static_assert(k > 0, "k > 0"); private: @@ -113,8 +113,8 @@ namespace sprout { return generate_1( rng_(), k == 1 ? BaseUnsigned(0) - : sprout::math::less(brange, std::numeric_limits::max() / k) ? BaseUnsigned(k * off / (brange + 1)) - : sprout::math::less(brange, std::numeric_limits::max() / k) + : sprout::math::less(brange, sprout::numeric_limits::max() / k) ? BaseUnsigned(k * off / (brange + 1)) + : sprout::math::less(brange, sprout::numeric_limits::max() / k) ? static_cast(static_cast(off) * k / (static_cast(brange) + 1)) //: static_cast(sprout::random::detail::muldiv(off, k, static_cast(brange) + 1)) // ??? : (SPROUT_ASSERT_MSG(0, "Sorry, not implemented."), sprout::random::random_result()) diff --git a/sprout/random/uniform_01.hpp b/sprout/random/uniform_01.hpp index bad3a814..24215b44 100644 --- a/sprout/random/uniform_01.hpp +++ b/sprout/random/uniform_01.hpp @@ -3,8 +3,8 @@ #include #include -#include #include +#include #include #ifdef SPROUT_WORKAROUND_NOT_TERMINATE_RECURSIVE_CONSTEXPR_FUNCTION_TEMPLATE # include @@ -76,7 +76,7 @@ namespace sprout { result_type(rnd.result() - eng.min()) * ( result_type(1) / ( result_type(eng.max() - eng.min()) + result_type( - std::numeric_limits::is_integer ? 1 : 0 + sprout::numeric_limits::is_integer ? 1 : 0 ) ) ) @@ -106,7 +106,7 @@ namespace sprout { result_type(rnd.result() - eng.min()) * ( result_type(1) / ( result_type(eng.max() - eng.min()) + result_type( - std::numeric_limits::is_integer ? 1 : 0 + sprout::numeric_limits::is_integer ? 1 : 0 ) ) ) diff --git a/sprout/random/uniform_int_distribution.hpp b/sprout/random/uniform_int_distribution.hpp index 4b6aef0a..341ba663 100644 --- a/sprout/random/uniform_int_distribution.hpp +++ b/sprout/random/uniform_int_distribution.hpp @@ -1,11 +1,11 @@ #ifndef SPROUT_RANDOM_UNIFORM_INT_DISTRIBUTION_HPP #define SPROUT_RANDOM_UNIFORM_INT_DISTRIBUTION_HPP -#include #include #include #include #include +#include #include #include #include @@ -100,7 +100,7 @@ namespace sprout { return sprout::random::detail::generate_uniform_int_true_3_1( eng(), min_value, range, bmin, brange, - brange == std::numeric_limits::max() + brange == sprout::numeric_limits::max() ? brange / (static_cast(range) + 1) + ( brange % (static_cast(range) + 1) == static_cast(range) ? 1 : 0 ) @@ -160,7 +160,7 @@ namespace sprout { BaseResult bmin, BaseUnsigned brange, RangeType result, RangeType mult, RangeType result_increment ) { - return std::numeric_limits::max() / mult < result_increment + return sprout::numeric_limits::max() / mult < result_increment ? sprout::random::detail::generate_uniform_int_true_2(eng, min_value, range, bmin, brange) : sprout::random::detail::generate_uniform_int_true_2_4( eng, min_value, range, @@ -290,7 +290,7 @@ namespace sprout { return sprout::random::detail::generate_uniform_int_true_2_1( eng, min_value, range, bmin, brange, - range == std::numeric_limits::max() + range == sprout::numeric_limits::max() ? range / (RangeType(brange) + 1) + ( range % (RangeType(brange) + 1) == RangeType(brange) ? 1 : 0 ) @@ -465,7 +465,7 @@ namespace sprout { return sprout::random::detail::generate_uniform_int_true_3_1( eng(), min_value, range, bmin, brange, - brange == std::numeric_limits::max() + brange == sprout::numeric_limits::max() ? brange / (static_cast(range) + 1) + ( brange % (static_cast(range) + 1) == static_cast(range) ? 1 : 0 ) @@ -501,7 +501,7 @@ namespace sprout { BaseResult bmin, BaseUnsigned brange, RangeType result, RangeType mult, RangeType result_increment ) { - return std::numeric_limits::max() / mult < result_increment + return sprout::numeric_limits::max() / mult < result_increment ? sprout::random::detail::generate_uniform_int_true_2(eng, min_value, range, bmin, brange) : sprout::random::detail::generate_uniform_int_true_2_4( eng, min_value, range, @@ -587,7 +587,7 @@ namespace sprout { return sprout::random::detail::generate_uniform_int_true_2_1( eng, min_value, range, bmin, brange, - range == std::numeric_limits::max() + range == sprout::numeric_limits::max() ? range / (RangeType(brange) + 1) + ( range % (RangeType(brange) + 1) == RangeType(brange) ? 1 : 0 ) diff --git a/sprout/range/adaptor/sawtooth_wave.hpp b/sprout/range/adaptor/sawtooth_wave.hpp index b6205c4b..7f949c0b 100644 --- a/sprout/range/adaptor/sawtooth_wave.hpp +++ b/sprout/range/adaptor/sawtooth_wave.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_RANGE_ADAPTOR_SAWTOOTH_WAVE_HPP #define SPROUT_RANGE_ADAPTOR_SAWTOOTH_WAVE_HPP -#include #include #include +#include #include #include #include @@ -81,7 +81,7 @@ namespace sprout { ) : base_type( iterator(0, frequency, amplitude, phase), - iterator(std::numeric_limits::max(), frequency, amplitude, phase) + iterator(sprout::numeric_limits::max(), frequency, amplitude, phase) ) {} SPROUT_CONSTEXPR value_type const& frequency() const { diff --git a/sprout/range/adaptor/sinusoidal.hpp b/sprout/range/adaptor/sinusoidal.hpp index dcd83323..5614a703 100644 --- a/sprout/range/adaptor/sinusoidal.hpp +++ b/sprout/range/adaptor/sinusoidal.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_RANGE_ADAPTOR_SINUSOIDAL_HPP #define SPROUT_RANGE_ADAPTOR_SINUSOIDAL_HPP -#include #include #include +#include #include #include #include @@ -81,7 +81,7 @@ namespace sprout { ) : base_type( iterator(0, frequency, amplitude, phase), - iterator(std::numeric_limits::max(), frequency, amplitude, phase) + iterator(sprout::numeric_limits::max(), frequency, amplitude, phase) ) {} SPROUT_CONSTEXPR value_type frequency() const { diff --git a/sprout/range/adaptor/square_wave.hpp b/sprout/range/adaptor/square_wave.hpp index 4d77de69..beaf756e 100644 --- a/sprout/range/adaptor/square_wave.hpp +++ b/sprout/range/adaptor/square_wave.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_RANGE_ADAPTOR_SQUARE_WAVE_HPP #define SPROUT_RANGE_ADAPTOR_SQUARE_WAVE_HPP -#include #include #include +#include #include #include #include @@ -86,7 +86,7 @@ namespace sprout { ) : base_type( iterator(0, frequency, amplitude, phase, duty), - iterator(std::numeric_limits::max(), frequency, amplitude, phase, duty) + iterator(sprout::numeric_limits::max(), frequency, amplitude, phase, duty) ) {} SPROUT_CONSTEXPR value_type frequency() const { diff --git a/sprout/range/adaptor/triangle_wave.hpp b/sprout/range/adaptor/triangle_wave.hpp index c1516a64..6a5cbf75 100644 --- a/sprout/range/adaptor/triangle_wave.hpp +++ b/sprout/range/adaptor/triangle_wave.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_RANGE_ADAPTOR_TRIANGLE_WAVE_HPP #define SPROUT_RANGE_ADAPTOR_TRIANGLE_WAVE_HPP -#include #include #include +#include #include #include #include @@ -81,7 +81,7 @@ namespace sprout { ) : base_type( iterator(0, frequency, amplitude, phase), - iterator(std::numeric_limits::max(), frequency, amplitude, phase) + iterator(sprout::numeric_limits::max(), frequency, amplitude, phase) ) {} SPROUT_CONSTEXPR value_type frequency() const { diff --git a/sprout/rational/rational.hpp b/sprout/rational/rational.hpp index a5e0dff1..4ac4d204 100644 --- a/sprout/rational/rational.hpp +++ b/sprout/rational/rational.hpp @@ -1,9 +1,9 @@ #ifndef SPROUT_RATIONAL_RATIONAL_HPP #define SPROUT_RATIONAL_RATIONAL_HPP -#include #include #include +#include #include #include #include @@ -57,7 +57,7 @@ namespace sprout { class rational : private sprout::detail::rational_impl { - static_assert(std::numeric_limits::is_specialized, "std::numeric_limits::is_specialized"); + static_assert(sprout::numeric_limits::is_specialized, "sprout::numeric_limits::is_specialized"); public: typedef IntType int_type; typedef typename sprout::detail::call_traits::param_type param_type; diff --git a/sprout/string/float_to_string.hpp b/sprout/string/float_to_string.hpp index e03563bb..b49b3169 100644 --- a/sprout/string/float_to_string.hpp +++ b/sprout/string/float_to_string.hpp @@ -2,9 +2,9 @@ #define SPROUT_STRING_FLOAT_TO_STRING_HPP #include -#include #include #include +#include #include #include #include @@ -29,7 +29,7 @@ namespace sprout { struct printed_float_digits : public std::integral_constant< std::size_t, - std::numeric_limits::max_exponent10 + sprout::detail::decimal_places_length + 2 + sprout::numeric_limits::max_exponent10 + sprout::detail::decimal_places_length + 2 > {}; @@ -103,7 +103,7 @@ namespace sprout { struct printed_float_exponent10_digits : public std::integral_constant< std::size_t, - NS_SSCRISK_CEL_OR_SPROUT::max(sprout::detail::int_digits(std::numeric_limits::max_exponent10), 2) + NS_SSCRISK_CEL_OR_SPROUT::max(sprout::detail::int_digits(sprout::numeric_limits::max_exponent10), 2) > {}; } // namespace detail diff --git a/sprout/utility/limited.hpp b/sprout/utility/limited.hpp index 8b57eb2a..3e2c26ad 100644 --- a/sprout/utility/limited.hpp +++ b/sprout/utility/limited.hpp @@ -1,8 +1,8 @@ #ifndef SPROUT_INTEGER_LIMITED_HPP #define SPROUT_INTEGER_LIMITED_HPP -#include #include +#include #include namespace sprout { @@ -14,10 +14,10 @@ namespace sprout { inline SPROUT_CONSTEXPR typename sprout::arithmetic_promote::type plus(T const& lhs, U const& rhs) { typedef typename sprout::arithmetic_promote::type type; - return lhs > 0 && rhs > 0 && std::numeric_limits::max() - lhs < rhs - ? std::numeric_limits::max() - : lhs < 0 && rhs < 0 && std::numeric_limits::min() - lhs > rhs - ? std::numeric_limits::min() + return lhs > 0 && rhs > 0 && sprout::numeric_limits::max() - lhs < rhs + ? sprout::numeric_limits::max() + : lhs < 0 && rhs < 0 && sprout::numeric_limits::min() - lhs > rhs + ? sprout::numeric_limits::min() : lhs + rhs ; } @@ -29,14 +29,14 @@ namespace sprout { inline SPROUT_CONSTEXPR typename sprout::arithmetic_promote::type multiplies(T const& lhs, U const& rhs) { typedef typename sprout::arithmetic_promote::type type; - return lhs > 0 && rhs > 0 && std::numeric_limits::max() / lhs + (std::numeric_limits::max() % lhs ? 1 : 0) <= rhs - ? std::numeric_limits::max() - : lhs > 0 && rhs < 0 && std::numeric_limits::min() / rhs + (std::numeric_limits::min() % rhs ? 1 : 0) <= lhs - ? std::numeric_limits::min() - : lhs < 0 && rhs > 0 && std::numeric_limits::min() / lhs + (std::numeric_limits::min() % lhs ? 1 : 0) <= rhs - ? std::numeric_limits::min() - : lhs < 0 && rhs < 0 && -(std::numeric_limits::min() / rhs + (std::numeric_limits::min() % rhs ? 1 : 0)) >= lhs - ? std::numeric_limits::max() + return lhs > 0 && rhs > 0 && sprout::numeric_limits::max() / lhs + (sprout::numeric_limits::max() % lhs ? 1 : 0) <= rhs + ? sprout::numeric_limits::max() + : lhs > 0 && rhs < 0 && sprout::numeric_limits::min() / rhs + (sprout::numeric_limits::min() % rhs ? 1 : 0) <= lhs + ? sprout::numeric_limits::min() + : lhs < 0 && rhs > 0 && sprout::numeric_limits::min() / lhs + (sprout::numeric_limits::min() % lhs ? 1 : 0) <= rhs + ? sprout::numeric_limits::min() + : lhs < 0 && rhs < 0 && -(sprout::numeric_limits::min() / rhs + (sprout::numeric_limits::min() % rhs ? 1 : 0)) >= lhs + ? sprout::numeric_limits::max() : lhs * rhs ; } diff --git a/sprout/uuid/random_generator.hpp b/sprout/uuid/random_generator.hpp index f8b07b96..a5027ff0 100644 --- a/sprout/uuid/random_generator.hpp +++ b/sprout/uuid/random_generator.hpp @@ -2,9 +2,9 @@ #define SPROUT_UUID_RANDOM_GENERATOR_HPP #include -#include #include #include +#include #include #include #include @@ -62,7 +62,7 @@ namespace sprout { } public: SPROUT_CONSTEXPR basic_random_generator() - : distribution_(std::numeric_limits::min(), std::numeric_limits::max()) + : distribution_(sprout::numeric_limits::min(), sprout::numeric_limits::max()) {} template SPROUT_CONSTEXPR typename std::enable_if< diff --git a/testspr/header_all.hpp b/testspr/header_all.hpp index 47104957..bedaf083 100644 --- a/testspr/header_all.hpp +++ b/testspr/header_all.hpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include