diff --git a/sprout/math/float2_exponent.hpp b/sprout/math/float2_exponent.hpp index 2398cefe..493830df 100644 --- a/sprout/math/float2_exponent.hpp +++ b/sprout/math/float2_exponent.hpp @@ -1,7 +1,6 @@ #ifndef SPROUT_MATH_FLOAT2_EXPONENT_HPP #define SPROUT_MATH_FLOAT2_EXPONENT_HPP -#include #include #include #include diff --git a/sprout/math/float2_sig_exp.hpp b/sprout/math/float2_sig_exp.hpp index d633ef9f..bf011377 100644 --- a/sprout/math/float2_sig_exp.hpp +++ b/sprout/math/float2_sig_exp.hpp @@ -1,7 +1,6 @@ #ifndef SPROUT_MATH_FLOAT2_SIG_EXP_HPP #define SPROUT_MATH_FLOAT2_SIG_EXP_HPP -#include #include #include #include diff --git a/sprout/math/is_even.hpp b/sprout/math/is_even.hpp index c4705c75..26534a67 100644 --- a/sprout/math/is_even.hpp +++ b/sprout/math/is_even.hpp @@ -4,18 +4,27 @@ #include #include #include +#include #include namespace sprout { namespace math { namespace detail { + template + inline SPROUT_CONSTEXPR bool + is_even_unchecked(T x) { + return sprout::math::fmod(x, T(2)) == T(0); + } + template< typename FloatType, typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR bool is_even(FloatType x) { - return sprout::math::fmod(x, FloatType(2)) == FloatType(0); + return sprout::math::isfinite(x) + && sprout::math::detail::is_even_unchecked(x) + ; } } // namespace detail diff --git a/sprout/math/is_integer.hpp b/sprout/math/is_integer.hpp index 2ce00093..7011329d 100644 --- a/sprout/math/is_integer.hpp +++ b/sprout/math/is_integer.hpp @@ -4,18 +4,27 @@ #include #include #include +#include #include namespace sprout { namespace math { namespace detail { + template + inline SPROUT_CONSTEXPR bool + is_integer_unchecked(T x) { + return x == sprout::math::trunc(x); + } + template< typename FloatType, typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR bool is_integer(FloatType x) { - return x == sprout::math::trunc(x); + return sprout::math::isfinite(x) + && sprout::math::detail::is_integer_unchecked(x) + ; } } // namespace detail diff --git a/sprout/math/is_odd.hpp b/sprout/math/is_odd.hpp index 23596757..6c5909fa 100644 --- a/sprout/math/is_odd.hpp +++ b/sprout/math/is_odd.hpp @@ -4,18 +4,27 @@ #include #include #include +#include #include namespace sprout { namespace math { namespace detail { + template + inline SPROUT_CONSTEXPR bool + is_odd_unchecked(T x) { + return sprout::math::fmod(x, T(2)) == T(1); + } + template< typename FloatType, typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR bool is_odd(FloatType x) { - return sprout::math::fmod(x, FloatType(2)) == FloatType(1); + return sprout::math::isfinite(x) + && sprout::math::detail::is_odd_unchecked(x) + ; } } // namespace detail diff --git a/sprout/optional/optional.hpp b/sprout/optional/optional.hpp index d2b061af..ee61baa4 100644 --- a/sprout/optional/optional.hpp +++ b/sprout/optional/optional.hpp @@ -38,6 +38,7 @@ namespace sprout { init = false; } public: + // 20.5.4.1, constructors SPROUT_CONSTEXPR optional() SPROUT_NOEXCEPT : init(false) {} @@ -61,7 +62,7 @@ namespace sprout { : init(v.is_initialized()) , val(v.is_initialized() ? holder_type(*v) : holder_type()) {} - + // 20.5.4.3, assignment optional& operator=(sprout::nullopt_t v) SPROUT_NOEXCEPT { assign(v); return *this; @@ -106,14 +107,14 @@ namespace sprout { void reset(argument_type v) { assign(v); } - + // 20.5.4.4, swap void swap(optional& other) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::swap(val, other.val))) { sprout::swap(init, other.init); sprout::swap(val, other.val); } - + // 20.5.4.5, observers SPROUT_CONSTEXPR reference_const_type operator*() const { return (SPROUT_ASSERT(is_initialized()), true) ? val.get() : val.get()