Hi,
I have this snippet of code and I'm trying to understand if I'm doing something wrong, or whether this is expected to work.
I want "max" to be the reduction function in transform_reduce, and so I passed std::max<int> as the argument, but it resulted in a compilation error (below). When I use an equivalent lambda, it works.
--- tr.cc ---
#include <numeric>
#include <vector>
struct S {
int v;
};
int fred(std::vector<S> &v) {
// Works
return std::transform_reduce(v.begin(), v.end(), 0,
(const int &a, const int &b) { return std::max<int>(a, b); },
(const S &s) { return s.v; });
// Fails
// return std::transform_reduce(v.begin(), v.end(), 0,
// std::max<int>,
// (const S &s) { return s.v; });
}