I am trying to combine std::accumulate
with std::min
. Something like this (won\'t compile):
vector V{2,1,3};
cout <&l
The problem is that there are several overloads of the min function:
template const T& min(const T& a, const T& b);
template
const T& min(const T& a, const T& b, BinaryPredicate comp);
Therefore, your code is ambiguous, the compiler does not know which overload to choose. You can state which one you want by using an intermediate function pointer:
#include
#include
#include
int main()
{
std::vector V{2,1,3};
int const & (*min) (int const &, int const &) = std::min;
std::cout << std::accumulate(V.begin() + 1, V.end(), V.front(), min);
}