This example taken straight off cppreference works fine but when I change accumulate to reduce (from what I can tell the two functions accept the same arguments and work the same in this context) it fails to compile. Any idea why?
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
int main()
{
std::vector<int> v{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
auto dash_fold = [](std::string a, int b) {
return std::move(a) + '-' + std::to_string(b);
};
//if changed to std::reduce it will not compile
std::string s = std::accumulate(std::next(v.begin()), v.end(),
std::to_string(v[0]), // start with first element
dash_fold);
}
Also tried using https://www.programiz.com/cpp-programming/online-compiler/ which also has the same result. MSVC compiles fine.
