Skip to content

Commit fb6e9f2

Browse files
author
ecrypa
committed
implement feedback from brunocodutra#100 (comment)
1 parent 9f001e8 commit fb6e9f2

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

include/metal/detail/sfinae.hpp

-9
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,6 @@ namespace metal {
5858
template<template<typename...> class expr, typename... vals>
5959
using call = expr<vals...>;
6060
#endif
61-
62-
template<class... vals>
63-
struct _dcaller {
64-
template<template<class...> class expr>
65-
using type = expr<vals...>;
66-
};
67-
68-
template<template<class...> class expr, class... vals>
69-
using dcall = typename _dcaller<vals...>::template type<expr>;
7061
}
7162
/// \endcond
7263
}

include/metal/list/min_element.hpp

+10-9
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,32 @@
22
#define METAL_LIST_MIN_ELEMENT_HPP
33

44
#include "../config.hpp"
5-
#include "../detail/sfinae.hpp"
65
#include "../lambda/apply.hpp"
6+
#include "../lambda/invoke.hpp"
77
#include "../lambda/lambda.hpp"
88
#include "../number/if.hpp"
9+
#include "../number/number.hpp"
910
#include "../value/fold_left.hpp"
1011

1112
namespace metal {
1213
namespace detail {
13-
1414
template<class lbd>
15-
struct _min_element {};
16-
17-
template<template<class...> class expr>
18-
struct _min_element<lambda<expr>> {
15+
struct _min_element {
1916
template<class x, class y>
20-
using combiner = if_<dcall<expr, y, x>, y, x>;
17+
using combiner = if_<invoke<lbd, y, x>, y, x>;
18+
// Combiner must use `invoke` in order to support SFINAE. It is
19+
// tempting to extract the `expr` from `lbd` and use `expr<y, x>`,
20+
// but that is not SFINAE-friendly.
2121

2222
template<class... vals>
2323
using type = fold_left<lambda<combiner>, vals...>;
2424
};
2525
}
2626

2727
template<class seq, class lbd>
28-
using min_element =
29-
apply<lambda<detail::_min_element<lbd>::template type>, seq>;
28+
using min_element = apply<
29+
lambda<detail::_min_element<if_<is_lambda<lbd>, lbd>>::template type>,
30+
seq>;
3031
}
3132

3233
#endif

0 commit comments

Comments
 (0)