diff --git a/sprout/bitset/bitset.hpp b/sprout/bitset/bitset.hpp index e5a4d630..ae0a28af 100644 --- a/sprout/bitset/bitset.hpp +++ b/sprout/bitset/bitset.hpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT namespace sprout { diff --git a/sprout/cinttypes/div.hpp b/sprout/cinttypes/div.hpp index c2d1036a..7bb804ea 100644 --- a/sprout/cinttypes/div.hpp +++ b/sprout/cinttypes/div.hpp @@ -13,9 +13,15 @@ #if !defined(_MSC_VER) # include #endif +#include #include #include #include +#include +#include +#include +#include +#include namespace sprout { // @@ -91,4 +97,106 @@ namespace sprout { } } // namespace sprout +namespace sprout { + // + // hash_value + // + inline SPROUT_CONSTEXPR std::size_t + hash_value(sprout::imaxdiv_t const& v) { + return sprout::hash_values(v.quot, v.rem); + } +} // namespace sprout + +namespace sprout { + namespace tuples { + namespace detail { + template + struct tuple_element_impl; + template + struct tuple_element_impl + : public sprout::detail::nil_base + {}; + template<> + struct tuple_element_impl<0, sprout::imaxdiv_t> + : public sprout::identity + {}; + template<> + struct tuple_element_impl<1, sprout::imaxdiv_t> + : public sprout::identity + {}; + + template + struct get_impl; + template<> + struct get_impl<0, sprout::imaxdiv_t> { + public: + SPROUT_CONSTEXPR std::intmax_t& operator()(sprout::imaxdiv_t& t) const { + return t.quot; + } + SPROUT_CONSTEXPR std::intmax_t const& operator()(sprout::imaxdiv_t const& t) const { + return t.quot; + } + }; + template<> + struct get_impl<1, sprout::imaxdiv_t> { + public: + SPROUT_CONSTEXPR std::intmax_t& operator()(sprout::imaxdiv_t& t) const { + return t.rem; + } + SPROUT_CONSTEXPR std::intmax_t const& operator()(sprout::imaxdiv_t const& t) const { + return t.rem; + } + }; + } // namespace detail + } // namespace tuples +} // namespace sprout + +namespace std { +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wmismatched-tags" +#endif + // + // tuple_size + // + template<> + struct tuple_size + : public sprout::integral_constant + {}; + + // + // tuple_element + // + template + struct tuple_element + : public sprout::tuples::detail::tuple_element_impl + {}; +#if defined(__clang__) +# pragma clang diagnostic pop +#endif +} // namespace std + +namespace sprout { + // + // tuple_get + // + template + inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element::type& + tuple_get(sprout::imaxdiv_t& t) SPROUT_NOEXCEPT { + static_assert(I < 2, "tuple_get: index out of range"); + return sprout::tuples::detail::get_impl()(t); + } + template + inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element::type const& + tuple_get(sprout::imaxdiv_t const& t) SPROUT_NOEXCEPT { + static_assert(I < 2, "tuple_get: index out of range"); + return sprout::tuples::detail::get_impl()(t); + } + template + inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element::type&& + tuple_get(sprout::imaxdiv_t&& t) SPROUT_NOEXCEPT { + return sprout::move(sprout::tuples::get(t)); + } +} // namespace sprout + #endif // #ifndef SPROUT_CINTTYPES_DIV_HPP diff --git a/sprout/container/shrink_to_fit.hpp b/sprout/container/shrink_to_fit.hpp index 9adacb84..645e081c 100644 --- a/sprout/container/shrink_to_fit.hpp +++ b/sprout/container/shrink_to_fit.hpp @@ -55,7 +55,9 @@ namespace sprout { inline SPROUT_CXX14_CONSTEXPR typename std::enable_if< !sprout::detail::has_mem_shrink_to_fit::value >::type - container_shrink_to_fit_default(Container&&) {} + container_shrink_to_fit_default(Container&&) { + return ; + } } // namespace detail namespace container_detail { diff --git a/sprout/cstdlib/div.hpp b/sprout/cstdlib/div.hpp index 14a43935..daee2fcc 100644 --- a/sprout/cstdlib/div.hpp +++ b/sprout/cstdlib/div.hpp @@ -10,11 +10,25 @@ #define SPROUT_CSTDLIB_DIV_HPP #include +#include #include #include #include +#include +#include +#include +#include +#include namespace sprout { + // + // div_t + // ldiv_t + // lldiv_t + // + typedef std::div_t div_t; + typedef std::ldiv_t ldiv_t; + typedef std::lldiv_t lldiv_t; namespace detail { template @@ -29,9 +43,9 @@ namespace sprout { SPROUT_STATIC_CONSTEXPR std::size_t offsetof_rem = offsetof(DIV_T, rem); \ } - SPROUT_DETAIL_DIV_T_TRAITS_IMPL(int, std::div_t); - SPROUT_DETAIL_DIV_T_TRAITS_IMPL(long, std::ldiv_t); - SPROUT_DETAIL_DIV_T_TRAITS_IMPL(long long, std::lldiv_t); + SPROUT_DETAIL_DIV_T_TRAITS_IMPL(int, sprout::div_t); + SPROUT_DETAIL_DIV_T_TRAITS_IMPL(long, sprout::ldiv_t); + SPROUT_DETAIL_DIV_T_TRAITS_IMPL(long long, sprout::lldiv_t); # undef SPROUT_DETAIL_DIV_T_TRAITS_IMPL template @@ -64,30 +78,254 @@ namespace sprout { } // namespace detail // 7.20.6.2 div,ldiv,及び lldiv 関数 - inline SPROUT_CONSTEXPR std::div_t + inline SPROUT_CONSTEXPR sprout::div_t div(int numer, int denom) { return sprout::detail::div_impl(numer, denom); } - inline SPROUT_CONSTEXPR std::ldiv_t + inline SPROUT_CONSTEXPR sprout::ldiv_t ldiv(long numer, long denom) { return sprout::detail::div_impl(numer, denom); } - inline SPROUT_CONSTEXPR std::lldiv_t + inline SPROUT_CONSTEXPR sprout::lldiv_t lldiv(long long numer, long long denom) { return sprout::detail::div_impl(numer, denom); } - inline SPROUT_CONSTEXPR std::ldiv_t + inline SPROUT_CONSTEXPR sprout::ldiv_t div(long numer, long denom) { return sprout::ldiv(numer, denom); } - inline SPROUT_CONSTEXPR std::lldiv_t + inline SPROUT_CONSTEXPR sprout::lldiv_t div(long long numer, long long denom) { return sprout::lldiv(numer, denom); } } // namespace sprout +namespace sprout { + // + // hash_value + // + inline SPROUT_CONSTEXPR std::size_t + hash_value(sprout::div_t const& v) { + return sprout::hash_values(v.quot, v.rem); + } + inline SPROUT_CONSTEXPR std::size_t + hash_value(sprout::ldiv_t const& v) { + return sprout::hash_values(v.quot, v.rem); + } + inline SPROUT_CONSTEXPR std::size_t + hash_value(sprout::lldiv_t const& v) { + return sprout::hash_values(v.quot, v.rem); + } +} // namespace sprout + +namespace sprout { + namespace tuples { + namespace detail { + template + struct tuple_element_impl; + template + struct tuple_element_impl + : public sprout::detail::nil_base + {}; + template<> + struct tuple_element_impl<0, sprout::div_t> + : public sprout::identity + {}; + template<> + struct tuple_element_impl<1, sprout::div_t> + : public sprout::identity + {}; + template + struct tuple_element_impl + : public sprout::detail::nil_base + {}; + template<> + struct tuple_element_impl<0, sprout::ldiv_t> + : public sprout::identity + {}; + template<> + struct tuple_element_impl<1, sprout::ldiv_t> + : public sprout::identity + {}; + template + struct tuple_element_impl + : public sprout::detail::nil_base + {}; + template<> + struct tuple_element_impl<0, sprout::lldiv_t> + : public sprout::identity + {}; + template<> + struct tuple_element_impl<1, sprout::lldiv_t> + : public sprout::identity + {}; + + template + struct get_impl; + template<> + struct get_impl<0, sprout::div_t> { + public: + SPROUT_CONSTEXPR int& operator()(sprout::div_t& t) const { + return t.quot; + } + SPROUT_CONSTEXPR int const& operator()(sprout::div_t const& t) const { + return t.quot; + } + }; + template<> + struct get_impl<1, sprout::div_t> { + public: + SPROUT_CONSTEXPR int& operator()(sprout::div_t& t) const { + return t.rem; + } + SPROUT_CONSTEXPR int const& operator()(sprout::div_t const& t) const { + return t.rem; + } + }; + template<> + struct get_impl<0, sprout::ldiv_t> { + public: + SPROUT_CONSTEXPR long& operator()(sprout::ldiv_t& t) const { + return t.quot; + } + SPROUT_CONSTEXPR long const& operator()(sprout::ldiv_t const& t) const { + return t.quot; + } + }; + template<> + struct get_impl<1, sprout::ldiv_t> { + public: + SPROUT_CONSTEXPR long& operator()(sprout::ldiv_t& t) const { + return t.rem; + } + SPROUT_CONSTEXPR long const& operator()(sprout::ldiv_t const& t) const { + return t.rem; + } + }; + template<> + struct get_impl<0, sprout::lldiv_t> { + public: + SPROUT_CONSTEXPR long long& operator()(sprout::lldiv_t& t) const { + return t.quot; + } + SPROUT_CONSTEXPR long long const& operator()(sprout::lldiv_t const& t) const { + return t.quot; + } + }; + template<> + struct get_impl<1, sprout::lldiv_t> { + public: + SPROUT_CONSTEXPR long long& operator()(sprout::lldiv_t& t) const { + return t.rem; + } + SPROUT_CONSTEXPR long long const& operator()(sprout::lldiv_t const& t) const { + return t.rem; + } + }; + } // namespace detail + } // namespace tuples +} // namespace sprout + +namespace std { +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wmismatched-tags" +#endif + // + // tuple_size + // + template<> + struct tuple_size + : public sprout::integral_constant + {}; + template<> + struct tuple_size + : public sprout::integral_constant + {}; + template<> + struct tuple_size + : public sprout::integral_constant + {}; + + // + // tuple_element + // + template + struct tuple_element + : public sprout::tuples::detail::tuple_element_impl + {}; + template + struct tuple_element + : public sprout::tuples::detail::tuple_element_impl + {}; + template + struct tuple_element + : public sprout::tuples::detail::tuple_element_impl + {}; +#if defined(__clang__) +# pragma clang diagnostic pop +#endif +} // namespace std + +namespace sprout { + // + // tuple_get + // + template + inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element::type& + tuple_get(sprout::div_t& t) SPROUT_NOEXCEPT { + static_assert(I < 2, "tuple_get: index out of range"); + return sprout::tuples::detail::get_impl()(t); + } + template + inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element::type const& + tuple_get(sprout::div_t const& t) SPROUT_NOEXCEPT { + static_assert(I < 2, "tuple_get: index out of range"); + return sprout::tuples::detail::get_impl()(t); + } + template + inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element::type&& + tuple_get(sprout::div_t&& t) SPROUT_NOEXCEPT { + return sprout::move(sprout::tuples::get(t)); + } + template + inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element::type& + tuple_get(sprout::ldiv_t& t) SPROUT_NOEXCEPT { + static_assert(I < 2, "tuple_get: index out of range"); + return sprout::tuples::detail::get_impl()(t); + } + template + inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element::type const& + tuple_get(sprout::ldiv_t const& t) SPROUT_NOEXCEPT { + static_assert(I < 2, "tuple_get: index out of range"); + return sprout::tuples::detail::get_impl()(t); + } + template + inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element::type&& + tuple_get(sprout::ldiv_t&& t) SPROUT_NOEXCEPT { + return sprout::move(sprout::tuples::get(t)); + } + template + inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element::type& + tuple_get(sprout::lldiv_t& t) SPROUT_NOEXCEPT { + static_assert(I < 2, "tuple_get: index out of range"); + return sprout::tuples::detail::get_impl()(t); + } + template + inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element::type const& + tuple_get(sprout::lldiv_t const& t) SPROUT_NOEXCEPT { + static_assert(I < 2, "tuple_get: index out of range"); + return sprout::tuples::detail::get_impl()(t); + } + template + inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element::type&& + tuple_get(sprout::lldiv_t&& t) SPROUT_NOEXCEPT { + return sprout::move(sprout::tuples::get(t)); + } +} // namespace sprout + #endif // #ifndef SPROUT_CSTDLIB_DIV_HPP diff --git a/sprout/exempt_ptr.hpp b/sprout/exempt_ptr.hpp index f505296e..1b570f0c 100644 --- a/sprout/exempt_ptr.hpp +++ b/sprout/exempt_ptr.hpp @@ -14,6 +14,7 @@ #include #include #include +#include namespace sprout { // @@ -246,4 +247,32 @@ namespace sprout { } } // namespace sprout +namespace sprout { + // + // hash_value + // + template + inline SPROUT_CONSTEXPR std::size_t + hash_value(sprout::exempt_ptr const& v) { + return sprout::hash_value(v.get()); + } +} // namespace sprout + +namespace std { +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wmismatched-tags" +#endif + // + // hash + // + template + struct hash > + : public sprout::hash > + {}; +#if defined(__clang__) +# pragma clang diagnostic pop +#endif +} // namespace std + #endif // #ifndef SPROUT_EXEMPT_PTR_HPP diff --git a/sprout/math/comparison.hpp b/sprout/math/comparisons.hpp similarity index 75% rename from sprout/math/comparison.hpp rename to sprout/math/comparisons.hpp index b10e5a64..83871d1e 100644 --- a/sprout/math/comparison.hpp +++ b/sprout/math/comparisons.hpp @@ -9,6 +9,12 @@ #define SPROUT_MATH_COMPARISON_HPP #include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/sprout/math/functions.hpp b/sprout/math/functions.hpp index 07458991..10d80a8e 100644 --- a/sprout/math/functions.hpp +++ b/sprout/math/functions.hpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #endif // #ifndef SPROUT_MATH_FUNCTIONS_HPP diff --git a/sprout/math/isgreater.hpp b/sprout/math/isgreater.hpp new file mode 100644 index 00000000..4bc59674 --- /dev/null +++ b/sprout/math/isgreater.hpp @@ -0,0 +1,63 @@ +/*============================================================================= + Copyright (c) 2011-2014 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_MATH_ISGREATER_HPP +#define SPROUT_MATH_ISGREATER_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace math { + namespace detail { +#if SPROUT_USE_BUILTIN_CMATH_FUNCTION + template + inline SPROUT_CONSTEXPR bool + builtin_isgreater(FloatType x, FloatType y) { + return __builtin_isgreater(x, y); + } +#endif + } // namespace detail + // + // isgreater + // + template< + typename FloatType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR bool + isgreater(FloatType x, FloatType y) { + return +#if SPROUT_USE_BUILTIN_CMATH_FUNCTION + sprout::math::detail::builtin_isgreater(x, y) +#else + !sprout::math::isnan(x) && !sprout::math::isnan(y) && (x > y) +#endif + ; + } + template< + typename ArithmeticType1, + typename ArithmeticType2, + typename sprout::enabler_if< + std::is_arithmetic::value && std::is_arithmetic::value + >::type = sprout::enabler + > + inline SPROUT_CONSTEXPR bool + isgreater(ArithmeticType1 x, ArithmeticType2 y) { + typedef typename sprout::float_promote::type type; + return sprout::math::isgreater(static_cast(x), static_cast(y)); + } + } // namespace math + + using sprout::math::isgreater; +} // namespace sprout + +#endif // #ifndef SPROUT_MATH_ISGREATER_HPP diff --git a/sprout/math/isgreaterequal.hpp b/sprout/math/isgreaterequal.hpp new file mode 100644 index 00000000..1174fbc3 --- /dev/null +++ b/sprout/math/isgreaterequal.hpp @@ -0,0 +1,63 @@ +/*============================================================================= + Copyright (c) 2011-2014 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_MATH_ISGREATEREQUAL_HPP +#define SPROUT_MATH_ISGREATEREQUAL_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace math { + namespace detail { +#if SPROUT_USE_BUILTIN_CMATH_FUNCTION + template + inline SPROUT_CONSTEXPR bool + builtin_isgreaterequal(FloatType x, FloatType y) { + return __builtin_isgreaterequal(x, y); + } +#endif + } // namespace detail + // + // isgreaterequal + // + template< + typename FloatType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR bool + isgreaterequal(FloatType x, FloatType y) { + return +#if SPROUT_USE_BUILTIN_CMATH_FUNCTION + sprout::math::detail::builtin_isgreaterequal(x, y) +#else + !sprout::math::isnan(x) && !sprout::math::isnan(y) && (x >= y) +#endif + ; + } + template< + typename ArithmeticType1, + typename ArithmeticType2, + typename sprout::enabler_if< + std::is_arithmetic::value && std::is_arithmetic::value + >::type = sprout::enabler + > + inline SPROUT_CONSTEXPR bool + isgreaterequal(ArithmeticType1 x, ArithmeticType2 y) { + typedef typename sprout::float_promote::type type; + return sprout::math::isgreaterequal(static_cast(x), static_cast(y)); + } + } // namespace math + + using sprout::math::isgreaterequal; +} // namespace sprout + +#endif // #ifndef SPROUT_MATH_ISGREATEREQUAL_HPP diff --git a/sprout/math/isless.hpp b/sprout/math/isless.hpp new file mode 100644 index 00000000..4a4bde58 --- /dev/null +++ b/sprout/math/isless.hpp @@ -0,0 +1,63 @@ +/*============================================================================= + Copyright (c) 2011-2014 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_MATH_ISLESS_HPP +#define SPROUT_MATH_ISLESS_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace math { + namespace detail { +#if SPROUT_USE_BUILTIN_CMATH_FUNCTION + template + inline SPROUT_CONSTEXPR bool + builtin_isless(FloatType x, FloatType y) { + return __builtin_isless(x, y); + } +#endif + } // namespace detail + // + // isless + // + template< + typename FloatType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR bool + isless(FloatType x, FloatType y) { + return +#if SPROUT_USE_BUILTIN_CMATH_FUNCTION + sprout::math::detail::builtin_isless(x, y) +#else + !sprout::math::isnan(x) && !sprout::math::isnan(y) && (x < y) +#endif + ; + } + template< + typename ArithmeticType1, + typename ArithmeticType2, + typename sprout::enabler_if< + std::is_arithmetic::value && std::is_arithmetic::value + >::type = sprout::enabler + > + inline SPROUT_CONSTEXPR bool + isless(ArithmeticType1 x, ArithmeticType2 y) { + typedef typename sprout::float_promote::type type; + return sprout::math::isless(static_cast(x), static_cast(y)); + } + } // namespace math + + using sprout::math::isless; +} // namespace sprout + +#endif // #ifndef SPROUT_MATH_ISLESS_HPP diff --git a/sprout/math/islessequal.hpp b/sprout/math/islessequal.hpp new file mode 100644 index 00000000..1f2de836 --- /dev/null +++ b/sprout/math/islessequal.hpp @@ -0,0 +1,63 @@ +/*============================================================================= + Copyright (c) 2011-2014 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_MATH_ISLESSEQUAL_HPP +#define SPROUT_MATH_ISLESSEQUAL_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace math { + namespace detail { +#if SPROUT_USE_BUILTIN_CMATH_FUNCTION + template + inline SPROUT_CONSTEXPR bool + builtin_islessequal(FloatType x, FloatType y) { + return __builtin_islessequal(x, y); + } +#endif + } // namespace detail + // + // islessequal + // + template< + typename FloatType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR bool + islessequal(FloatType x, FloatType y) { + return +#if SPROUT_USE_BUILTIN_CMATH_FUNCTION + sprout::math::detail::builtin_islessequal(x, y) +#else + !sprout::math::isnan(x) && !sprout::math::isnan(y) && (x < y) +#endif + ; + } + template< + typename ArithmeticType1, + typename ArithmeticType2, + typename sprout::enabler_if< + std::is_arithmetic::value && std::is_arithmetic::value + >::type = sprout::enabler + > + inline SPROUT_CONSTEXPR bool + islessequal(ArithmeticType1 x, ArithmeticType2 y) { + typedef typename sprout::float_promote::type type; + return sprout::math::islessequal(static_cast(x), static_cast(y)); + } + } // namespace math + + using sprout::math::islessequal; +} // namespace sprout + +#endif // #ifndef SPROUT_MATH_ISLESSEQUAL_HPP diff --git a/sprout/math/islessgreater.hpp b/sprout/math/islessgreater.hpp new file mode 100644 index 00000000..b55a7757 --- /dev/null +++ b/sprout/math/islessgreater.hpp @@ -0,0 +1,63 @@ +/*============================================================================= + Copyright (c) 2011-2014 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_MATH_ISLESSGREATER_HPP +#define SPROUT_MATH_ISLESSGREATER_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace math { + namespace detail { +#if SPROUT_USE_BUILTIN_CMATH_FUNCTION + template + inline SPROUT_CONSTEXPR bool + builtin_islessgreater(FloatType x, FloatType y) { + return __builtin_islessgreater(x, y); + } +#endif + } // namespace detail + // + // islessgreater + // + template< + typename FloatType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR bool + islessgreater(FloatType x, FloatType y) { + return +#if SPROUT_USE_BUILTIN_CMATH_FUNCTION + sprout::math::detail::builtin_islessgreater(x, y) +#else + !sprout::math::isnan(x) && !sprout::math::isnan(y) && ((x < y) || (x > y)) +#endif + ; + } + template< + typename ArithmeticType1, + typename ArithmeticType2, + typename sprout::enabler_if< + std::is_arithmetic::value && std::is_arithmetic::value + >::type = sprout::enabler + > + inline SPROUT_CONSTEXPR bool + islessgreater(ArithmeticType1 x, ArithmeticType2 y) { + typedef typename sprout::float_promote::type type; + return sprout::math::islessgreater(static_cast(x), static_cast(y)); + } + } // namespace math + + using sprout::math::islessgreater; +} // namespace sprout + +#endif // #ifndef SPROUT_MATH_ISLESSGREATER_HPP diff --git a/sprout/math/isunordered.hpp b/sprout/math/isunordered.hpp new file mode 100644 index 00000000..e07d9b2a --- /dev/null +++ b/sprout/math/isunordered.hpp @@ -0,0 +1,63 @@ +/*============================================================================= + Copyright (c) 2011-2014 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_MATH_ISUNORDERED_HPP +#define SPROUT_MATH_ISUNORDERED_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace math { + namespace detail { +#if SPROUT_USE_BUILTIN_CMATH_FUNCTION + template + inline SPROUT_CONSTEXPR bool + builtin_isunordered(FloatType x, FloatType y) { + return __builtin_isunordered(x, y); + } +#endif + } // namespace detail + // + // isunordered + // + template< + typename FloatType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR bool + isunordered(FloatType x, FloatType y) { + return +#if SPROUT_USE_BUILTIN_CMATH_FUNCTION + sprout::math::detail::builtin_isunordered(x, y) +#else + sprout::math::isnan(x) || sprout::math::isnan(y) +#endif + ; + } + template< + typename ArithmeticType1, + typename ArithmeticType2, + typename sprout::enabler_if< + std::is_arithmetic::value && std::is_arithmetic::value + >::type = sprout::enabler + > + inline SPROUT_CONSTEXPR bool + isunordered(ArithmeticType1 x, ArithmeticType2 y) { + typedef typename sprout::float_promote::type type; + return sprout::math::isunordered(static_cast(x), static_cast(y)); + } + } // namespace math + + using sprout::math::isunordered; +} // namespace sprout + +#endif // #ifndef SPROUT_MATH_ISUNORDERED_HPP diff --git a/sprout/utility/unmove.hpp b/sprout/utility/unmove.hpp index 0fa20b8d..63d9eaa0 100644 --- a/sprout/utility/unmove.hpp +++ b/sprout/utility/unmove.hpp @@ -12,6 +12,9 @@ #include namespace sprout { + // + // unmove + // template inline SPROUT_CONSTEXPR typename std::remove_reference::type& unmove(T&& x) SPROUT_NOEXCEPT {