I have written a simple predicate which I want to pass to std::ranges::views::filter:
struct even_fn {
constexpr
bool operator()(std::integral auto&& e) const noexcept {
return e % 2 == 0;
}
};
inline constexpr even_fn even;
Sample usage:
using namespace std::ranges;
views::iota(1, 10) | views::filter(even);
This fails with a wall of errors with, I presume, the most meaningful one being:
note: the expression 'is_invocable_v<_Fn, _Args ...> [with _Fn = even_fn&; _Args = {std::__detail::__cond_value_type<int>::value_type&}]' evaluated to 'false'
However, if I remove the std::integral part from my operator (leaving just auto&&), the code compiles successfully. Why is that? What's so special about this __cond_value_type that breaks when we have constrained functors?