Using g++ with -std=C++20
or later, the following compiles (assuming vec is a vector of appropriate type):
auto isEven = [](auto i) { return i % 2 == 0; }
auto filtered = vec | std::views::filter(isEven);
auto minEven = std::ranges::min_element(filtered);
but the following does not (wrong number of arguments to std::ranges::__min_element_fn
):
auto isEven = [](auto i) { return i % 2 == 0; }
auto minEven = vec | std::views::filter(isEven) | std::ranges::min_element();
What is the rationale here? How do I know which of the spiffy range-related facilities can be incorporated in a pipe? (The latter is what I intuitively wrote; conceptually it would seem to be the "new ranges way" to do this.)