From 39a54655536f48da86a18e7e8e27baecbecefb32 Mon Sep 17 00:00:00 2001 From: ecrypa <> Date: Mon, 28 Oct 2019 20:26:47 +0100 Subject: [PATCH] brute-force attempt to fix min_element example on GCC 4.7 --- include/metal/list/min_element.hpp | 46 +++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/include/metal/list/min_element.hpp b/include/metal/list/min_element.hpp index 6a98c4c4..61fffbc9 100644 --- a/include/metal/list/min_element.hpp +++ b/include/metal/list/min_element.hpp @@ -4,7 +4,6 @@ #include "../config.hpp" #include "../detail/sfinae.hpp" #include "../lambda/lambda.hpp" -#include "../number/if.hpp" #include "../number/less.hpp" namespace metal { @@ -53,32 +52,53 @@ namespace metal { /// \see min, sort #if !defined(METAL_WORKAROUND) template> - using min_element = detail::call< - detail::_min_element, lbd>>::template type, seq>; + using min_element = + detail::call::template type, seq>; #else // MSVC 14 has shabby SFINAE support in case of default alias template args template - using min_element = detail::call< - detail::_min_element, lbd>...>::template type, seq>; + using min_element = + detail::call::template type, seq>; #endif } -#include "../lambda/apply.hpp" -#include "../lambda/invoke.hpp" -#include "../lambda/partial.hpp" +#include "../list/list.hpp" +#include "../number/if.hpp" #include "../value/fold_left.hpp" namespace metal { /// \cond namespace detail { - template - struct _min_element { + template + struct _min_element_min_impl { + template class expr> + using type = if_, y, x>; + }; + + template class expr> + struct _min_element_min { template - using custom_min = if_, y, x>; + using type = + forward<_min_element_min_impl::template type, expr>; + }; + template + struct _min_element_impl {}; + + template + struct _min_element_impl> { + template class expr> + using type = fold_left< + lambda<_min_element_min::template type>, vals...>; + }; + + template + struct _min_element {}; + + template class expr> + struct _min_element> { template - using type = - apply, lambda>, seq>; + using type = forward<_min_element_impl::template type, expr>; }; } /// \endcond