From a55c430f091a923d01f3519f30ca7588e9c46517 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Mon, 22 Apr 2013 23:55:30 +0900 Subject: [PATCH] add math tgamma --- sprout/container/begin.hpp | 12 +- sprout/container/end.hpp | 12 +- sprout/functional/hash/to_hash.hpp | 7 + sprout/generator/generated_value.hpp | 19 ++- sprout/generator/generator_access_traits.hpp | 28 ++-- sprout/generator/next_generator.hpp | 21 ++- sprout/math/cmath.hpp | 1 + sprout/math/gamma.hpp | 7 + sprout/math/tgamma.hpp | 141 +++++++++++++++++++ sprout/tuple/tuple/get.hpp | 16 ++- 10 files changed, 224 insertions(+), 40 deletions(-) create mode 100644 sprout/math/gamma.hpp create mode 100644 sprout/math/tgamma.hpp diff --git a/sprout/container/begin.hpp b/sprout/container/begin.hpp index 2aa919ec..f5695227 100644 --- a/sprout/container/begin.hpp +++ b/sprout/container/begin.hpp @@ -28,6 +28,12 @@ namespace sprout { // // begin // + // effect: + // ADL callable range_begin(cont) -> range_begin(cont) + // otherwise -> sprout::container_range_traits::range_begin(cont) + // [default] + // cont.begin() + // template inline SPROUT_CONSTEXPR typename sprout::container_traits::iterator begin(Container& cont) { @@ -59,14 +65,12 @@ namespace sprout { template inline SPROUT_CONSTEXPR typename sprout::container_traits::iterator cbegin(Container const& cont) { - using sprout::container_detail::range_begin; - using sprout_adl::range_begin; - return range_begin(cont); + return sprout::begin(cont); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::iterator cbegin(T const (& arr)[N]) { - return sprout::container_detail::range_begin(arr); + return sprout::begin(arr); } } // namespace sprout diff --git a/sprout/container/end.hpp b/sprout/container/end.hpp index b87fe422..1b9be39e 100644 --- a/sprout/container/end.hpp +++ b/sprout/container/end.hpp @@ -28,6 +28,12 @@ namespace sprout { // // end // + // effect: + // ADL callable range_end(cont) -> range_end(cont) + // otherwise -> sprout::container_range_traits::range_end(cont) + // [default] + // cont.end() + // template inline SPROUT_CONSTEXPR typename sprout::container_traits::iterator end(Container& cont) { @@ -59,14 +65,12 @@ namespace sprout { template inline SPROUT_CONSTEXPR typename sprout::container_traits::iterator cend(Container const& cont) { - using sprout::container_detail::range_end; - using sprout_adl::range_end; - return range_end(cont); + return sprout::end(cont); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::iterator cend(T const (& arr)[N]) { - return sprout::container_detail::range_end(arr); + return sprout::end(arr); } } // namespace sprout diff --git a/sprout/functional/hash/to_hash.hpp b/sprout/functional/hash/to_hash.hpp index 16c2bff7..83ffc89f 100644 --- a/sprout/functional/hash/to_hash.hpp +++ b/sprout/functional/hash/to_hash.hpp @@ -15,6 +15,13 @@ namespace sprout { // // to_hash // + // effect: + // ADL callable hash_value(v) -> hash_value(v) + // otherwise -> sprout::hash_value_traits::hash_value(v) + // [default] + // v is Arithmetic || Enum || Pointer || Array -> implementation-defined + // otherwise -> std::hash()(v) + // template inline SPROUT_CONSTEXPR std::size_t to_hash(T&& v) { diff --git a/sprout/generator/generated_value.hpp b/sprout/generator/generated_value.hpp index 9149f147..9dccbc24 100644 --- a/sprout/generator/generated_value.hpp +++ b/sprout/generator/generated_value.hpp @@ -18,7 +18,7 @@ namespace sprout_generator_detail { template inline SPROUT_CONSTEXPR decltype(sprout::generators::generator_access_traits::get_generated_value(std::declval())) get_generated_value(Gen& gen) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits::get_generated_value(std::declval()))) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits::get_generated_value(std::declval()))) { return sprout::generators::generator_access_traits::get_generated_value(gen); } @@ -28,14 +28,14 @@ namespace sprout_generator_detail { decltype(sprout::generators::generator_access_traits::type>::get_generated_value(std::declval())) >::type get_generated_value(Gen&& gen) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits::type>::get_generated_value(std::declval()))) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits::type>::get_generated_value(std::declval()))) { return sprout::generators::generator_access_traits::get_generated_value(gen); } template inline SPROUT_CONSTEXPR decltype(sprout::generators::generator_access_traits::get_generated_value(std::declval())) get_generated_value(Gen const& gen) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits::get_generated_value(std::declval()))) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits::get_generated_value(std::declval()))) { return sprout::generators::generator_access_traits::get_generated_value(gen); } @@ -43,7 +43,7 @@ namespace sprout_generator_detail { template inline SPROUT_CONSTEXPR decltype(get_generated_value(std::declval())) call_get_generated_value(Gen& gen) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(get_generated_value(std::declval()))) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(get_generated_value(std::declval()))) { return get_generated_value(gen); } @@ -53,14 +53,14 @@ namespace sprout_generator_detail { decltype(get_generated_value(std::declval())) >::type call_get_generated_value(Gen&& gen) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(get_generated_value(std::declval()))) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(get_generated_value(std::declval()))) { return get_generated_value(gen); } template inline SPROUT_CONSTEXPR decltype(get_generated_value(std::declval())) call_get_generated_value(Gen const& gen) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(get_generated_value(std::declval()))) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(get_generated_value(std::declval()))) { return get_generated_value(gen); } @@ -71,6 +71,13 @@ namespace sprout { // // generated_value // + // effect: + // ADL callable get_generated_value(t) -> get_generated_value(t) + // otherwise -> sprout::generators::generator_access_traits::get_generated_value(t) + // [default] + // member callable t.generated_value() -> t.generated_value() + // otherwise -> sprout::tuples::get<0>(t) + // template inline SPROUT_CONSTEXPR decltype(sprout_generator_detail::call_get_generated_value(std::declval())) generated_value(T&& t) diff --git a/sprout/generator/generator_access_traits.hpp b/sprout/generator/generator_access_traits.hpp index abe5f585..59de63c1 100644 --- a/sprout/generator/generator_access_traits.hpp +++ b/sprout/generator/generator_access_traits.hpp @@ -41,19 +41,19 @@ namespace sprout { public: static SPROUT_CONSTEXPR decltype(std::declval().generated_value()) get_generated_value(Gen& t) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval().generated_value())) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval().generated_value())) { return t.generated_value(); } static SPROUT_CONSTEXPR decltype(std::declval().generated_value()) get_generated_value(Gen&& t) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval().generated_value())) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval().generated_value())) { return t.generated_value(); } static SPROUT_CONSTEXPR decltype(std::declval().generated_value()) get_generated_value(Gen const& t) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval().generated_value())) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval().generated_value())) { return t.generated_value(); } @@ -66,19 +66,19 @@ namespace sprout { public: static SPROUT_CONSTEXPR decltype(sprout::tuples::get<0>(std::declval())) get_generated_value(Gen& t) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<0>(std::declval()))) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<0>(std::declval()))) { return sprout::tuples::get<0>(t); } static SPROUT_CONSTEXPR decltype(sprout::tuples::get<0>(std::declval())) get_generated_value(Gen&& t) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<0>(std::declval()))) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<0>(std::declval()))) { return sprout::tuples::get<0>(t); } static SPROUT_CONSTEXPR decltype(sprout::tuples::get<0>(std::declval())) get_generated_value(Gen const& t) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<0>(std::declval()))) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<0>(std::declval()))) { return sprout::tuples::get<0>(t); } @@ -116,19 +116,19 @@ namespace sprout { public: static SPROUT_CONSTEXPR decltype(std::declval().next_generator()) get_next_generator(Gen& t) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval().next_generator())) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval().next_generator())) { return t.next_generator(); } static SPROUT_CONSTEXPR decltype(std::declval().next_generator()) get_next_generator(Gen&& t) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval().next_generator())) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval().next_generator())) { return t.next_generator(); } static SPROUT_CONSTEXPR decltype(std::declval().next_generator()) get_next_generator(Gen const& t) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval().next_generator())) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval().next_generator())) { return t.next_generator(); } @@ -141,19 +141,19 @@ namespace sprout { public: static SPROUT_CONSTEXPR decltype(sprout::tuples::get<1>(std::declval())) get_next_generator(Gen& t) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<1>(std::declval()))) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<1>(std::declval()))) { return sprout::tuples::get<1>(t); } static SPROUT_CONSTEXPR decltype(sprout::tuples::get<1>(std::declval())) get_next_generator(Gen&& t) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<1>(std::declval()))) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<1>(std::declval()))) { return sprout::tuples::get<1>(t); } static SPROUT_CONSTEXPR decltype(sprout::tuples::get<1>(std::declval())) get_next_generator(Gen const& t) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<1>(std::declval()))) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<1>(std::declval()))) { return sprout::tuples::get<1>(t); } @@ -173,13 +173,13 @@ namespace sprout { public: static SPROUT_CONSTEXPR decltype(sprout::generators::generator_access_traits::get_generated_value(std::declval())) get_generated_value(Gen const& t) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits::get_generated_value(std::declval()))) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits::get_generated_value(std::declval()))) { return sprout::generators::generator_access_traits::get_generated_value(t); } static SPROUT_CONSTEXPR decltype(sprout::generators::generator_access_traits::get_next_generator(std::declval())) get_next_generator(Gen const& t) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits::get_next_generator(std::declval()))) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits::get_next_generator(std::declval()))) { return sprout::generators::generator_access_traits::get_next_generator(t); } diff --git a/sprout/generator/next_generator.hpp b/sprout/generator/next_generator.hpp index 676a3e48..08cb9be4 100644 --- a/sprout/generator/next_generator.hpp +++ b/sprout/generator/next_generator.hpp @@ -18,7 +18,7 @@ namespace sprout_generator_detail { template inline SPROUT_CONSTEXPR decltype(sprout::generators::generator_access_traits::get_next_generator(std::declval())) get_next_generator(Gen& gen) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits::get_next_generator(std::declval()))) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits::get_next_generator(std::declval()))) { return sprout::generators::generator_access_traits::get_next_generator(gen); } @@ -28,14 +28,14 @@ namespace sprout_generator_detail { decltype(sprout::generators::generator_access_traits::type>::get_next_generator(std::declval())) >::type get_next_generator(Gen&& gen) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits::type>::get_next_generator(std::declval()))) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits::type>::get_next_generator(std::declval()))) { return sprout::generators::generator_access_traits::get_next_generator(gen); } template inline SPROUT_CONSTEXPR decltype(sprout::generators::generator_access_traits::get_next_generator(std::declval())) get_next_generator(Gen const& gen) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits::get_next_generator(std::declval()))) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits::get_next_generator(std::declval()))) { return sprout::generators::generator_access_traits::get_next_generator(gen); } @@ -43,7 +43,7 @@ namespace sprout_generator_detail { template inline SPROUT_CONSTEXPR decltype(get_next_generator(std::declval())) call_get_next_generator(Gen& gen) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(get_next_generator(std::declval()))) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(get_next_generator(std::declval()))) { return get_next_generator(gen); } @@ -53,14 +53,14 @@ namespace sprout_generator_detail { decltype(get_next_generator(std::declval())) >::type call_get_next_generator(Gen&& gen) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(get_next_generator(std::declval()))) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(get_next_generator(std::declval()))) { return get_next_generator(gen); } template inline SPROUT_CONSTEXPR decltype(get_next_generator(std::declval())) call_get_next_generator(Gen const& gen) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(get_next_generator(std::declval()))) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(get_next_generator(std::declval()))) { return get_next_generator(gen); } @@ -71,10 +71,17 @@ namespace sprout { // // next_generator // + // effect: + // ADL callable get_next_generator(t) -> get_next_generator(t) + // otherwise -> sprout::generators::generator_access_traits::get_next_generator(t) + // [default] + // member callable t.next_generator() -> t.next_generator() + // otherwise -> sprout::tuples::get<0>(t) + // template inline SPROUT_CONSTEXPR decltype(sprout_generator_detail::call_get_next_generator(std::declval())) next_generator(T&& t) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout_generator_detail::call_get_next_generator(std::declval()))) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout_generator_detail::call_get_next_generator(std::declval()))) { return sprout_generator_detail::call_get_next_generator(sprout::forward(t)); } diff --git a/sprout/math/cmath.hpp b/sprout/math/cmath.hpp index a160068b..b0abaa4e 100644 --- a/sprout/math/cmath.hpp +++ b/sprout/math/cmath.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include diff --git a/sprout/math/gamma.hpp b/sprout/math/gamma.hpp new file mode 100644 index 00000000..999c7a91 --- /dev/null +++ b/sprout/math/gamma.hpp @@ -0,0 +1,7 @@ +#ifndef SPROUT_MATH_GAMMA_HPP +#define SPROUT_MATH_GAMMA_HPP + +#include +#include + +#endif // #ifndef SPROUT_MATH_GAMMA_HPP diff --git a/sprout/math/tgamma.hpp b/sprout/math/tgamma.hpp new file mode 100644 index 00000000..f45274cd --- /dev/null +++ b/sprout/math/tgamma.hpp @@ -0,0 +1,141 @@ +#ifndef SPROUT_MATH_TGAMMA_HPP +#define SPROUT_MATH_TGAMMA_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT + +namespace sprout { + namespace math { + namespace detail { + template + inline SPROUT_CONSTEXPR T + tgamma_impl_y(T w) { + return (((((((((((( + -1.99542863674e-7 * w + 1.337767384067e-6) * w + - 2.591225267689e-6) * w - 1.7545539395205e-5) * w + + 1.45596568617526e-4) * w - 3.60837876648255e-4) * w + - 8.04329819255744e-4) * w + 0.008023273027855346) * w + - 0.017645244547851414) * w - 0.024552490005641278) * w + + 0.19109110138763841) * w - 0.233093736421782878) * w + - 0.422784335098466784) * w + 0.99999999999999999 + ; + } + template + inline SPROUT_CONSTEXPR T + tgamma_impl_t_pos(T x, std::size_t n, std::size_t last) { + return last - n == 1 + ? x - static_cast(n) + : sprout::math::detail::tgamma_impl_t_pos(x, n, n + (last - n) / 2) + * sprout::math::detail::tgamma_impl_t_pos(x, n + (last - n) / 2, last) + ; + } + template + inline SPROUT_CONSTEXPR T + tgamma_impl_t_neg(T x, std::size_t n, std::size_t last) { + return last - n == 1 + ? x + static_cast(n) + : sprout::math::detail::tgamma_impl_t_neg(x, n, n + (last - n) / 2) + * sprout::math::detail::tgamma_impl_t_neg(x, n + (last - n) / 2, last) + ; + } + template + inline SPROUT_CONSTEXPR T + tgamma_impl_t_pos_rec(T x, std::size_t n, std::size_t last) { + return last - n == 1 + ? T(1) / (x - static_cast(n)) + : sprout::math::detail::tgamma_impl_t_pos_rec(x, n, n + (last - n) / 2) + * sprout::math::detail::tgamma_impl_t_pos_rec(x, n + (last - n) / 2, last) + ; + } + template + inline SPROUT_CONSTEXPR T + tgamma_impl_t_neg_rec(T x, std::size_t n, std::size_t last) { + return last - n == 1 + ? T(1) / (x + static_cast(n)) + : sprout::math::detail::tgamma_impl_t_neg_rec(x, n, n + (last - n) / 2) + * sprout::math::detail::tgamma_impl_t_neg_rec(x, n + (last - n) / 2, last) + ; + } + template + inline SPROUT_CONSTEXPR T + tgamma_impl_2_pos(T x, T y, T t) { + return t == 0 ? std::numeric_limits::infinity() + : (x - T(1)) / y / t + ; + } + template + inline SPROUT_CONSTEXPR T + tgamma_impl_2_neg(T x, T y, T t) { + return t == 0 ? T(0) + : T(1) / y * t + ; + } + template + inline SPROUT_CONSTEXPR T + tgamma_impl_1(T x, int n) { + return n == 1 ? (x - T(1)) / sprout::math::detail::tgamma_impl_y(x - (n + 2)) + : n == 0 ? T(1) / sprout::math::detail::tgamma_impl_y(x - (n + 2)) + : n == static_cast(sprout::math::factorial_limit()) + ? sprout::math::detail::tgamma_impl_2_pos(x, sprout::math::detail::tgamma_impl_y(x - (n + 2)), sprout::math::detail::tgamma_impl_t_pos_rec(x, 2, n + 1)) + : n == -static_cast(sprout::math::factorial_limit()) +// ? sprout::math::detail::tgamma_impl_2_neg(x, sprout::math::detail::tgamma_impl_y(x - (n + 2)), sprout::math::detail::tgamma_impl_t_neg_rec(x, 0, -n)) + ? T(1) / sprout::math::detail::tgamma_impl_y(x - (n + 2)) * sprout::math::detail::tgamma_impl_t_neg_rec(x, 0, -n) + : n > 1 ? (x - T(1)) / sprout::math::detail::tgamma_impl_y(x - (n + 2)) * sprout::math::detail::tgamma_impl_t_pos(x, 2, n + 1) + : T(1) / sprout::math::detail::tgamma_impl_y(x - (n + 2)) / sprout::math::detail::tgamma_impl_t_neg(x, 0, -n) + ; + } + template + inline SPROUT_CONSTEXPR T + tgamma_impl(T x) { + return sprout::math::detail::tgamma_impl_1( + x, + sprout::clamp( + sprout::math::iround(x - T(2)), + -static_cast(sprout::math::factorial_limit()), + static_cast(sprout::math::factorial_limit()) + ) + ); + } + + template< + typename FloatType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR FloatType + tgamma(FloatType x) { + typedef typename sprout::math::detail::float_compute::type type; + return x == 0 ? std::numeric_limits::infinity() + : x == -std::numeric_limits::infinity() ? std::numeric_limits::quiet_NaN() + : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() + : x < 0 && x == std::trunc(x) ? std::numeric_limits::quiet_NaN() + : static_cast(sprout::math::detail::tgamma_impl(static_cast(x))) + ; + } + + template< + typename IntType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR double + tgamma(IntType x) { + return sprout::math::detail::tgamma(static_cast(x)); + } + } // namespace detail + + using NS_SPROUT_MATH_DETAIL::tgamma; + } // namespace math + + using sprout::math::tgamma; +} // namespace sprout + +#endif // #ifndef SPROUT_MATH_TGAMMA_HPP diff --git a/sprout/tuple/tuple/get.hpp b/sprout/tuple/tuple/get.hpp index 6fcf27a6..7b515061 100644 --- a/sprout/tuple/tuple/get.hpp +++ b/sprout/tuple/tuple/get.hpp @@ -62,7 +62,7 @@ namespace sprout_tuple_detail { template inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element::type& tuple_get(T& t) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::tuple_access_traits::template tuple_get(std::declval()))) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::tuple_access_traits::template tuple_get(std::declval()))) { return sprout::tuples::tuple_access_traits::template tuple_get(t); } @@ -72,14 +72,14 @@ namespace sprout_tuple_detail { typename sprout::tuples::tuple_element::type>::type&& >::type tuple_get(T&& t) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::tuple_access_traits::type>::template tuple_get(std::declval()))) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::tuple_access_traits::type>::template tuple_get(std::declval()))) { return sprout::tuples::tuple_access_traits::template tuple_get(t); } template inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element::type const& tuple_get(T const& t) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::tuple_access_traits::template tuple_get(std::declval()))) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::tuple_access_traits::template tuple_get(std::declval()))) { return sprout::tuples::tuple_access_traits::template tuple_get(t); } @@ -87,7 +87,7 @@ namespace sprout_tuple_detail { template inline SPROUT_CONSTEXPR decltype(tuple_get(std::declval())) call_tuple_get(T&& t) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(tuple_get(std::declval()))) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(tuple_get(std::declval()))) { return tuple_get(sprout::forward(t)); } @@ -98,10 +98,16 @@ namespace sprout { // // get // + // effect: + // ADL callable tuple_get(t) -> tuple_get(t) + // otherwise -> sprout::tuples::tuple_access_traits::tuple_get(t) + // [default] + // std::get(t) + // template inline SPROUT_CONSTEXPR decltype(sprout_tuple_detail::call_tuple_get(std::declval())) get(T&& t) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout_tuple_detail::call_tuple_get(std::declval()))) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout_tuple_detail::call_tuple_get(std::declval()))) { return sprout_tuple_detail::call_tuple_get(sprout::forward(t)); }