https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104251

--- Comment #5 from Felix Köhler <felix.koehler at gmail dot com> ---
Andrew, Jonathan,

thanks to both of you for the concise and helpful explanations! GCC not only is
a great compiler, it has a great STL and great implementers :D

So, if I want to replace an instance of accumulate, that uses a lambda to do
something with the range, the correct replacement would be a combination of
transform and reduce (or maybe transform_reduce)? The following yields 18 as
expected.

Like:
    vector<string> numbers={"eins","dos", "three", "quatre"};
    vector<size_t> L(numbers.size());
    transform(execution::par,
              numbers.begin(), numbers.end(),
              L.begin(),
              [](const string& s) -> std::size_t {return s.size(); });
    cout << reduce(execution::par, L.begin(), L.end()) << endl;

being equal to
    vector<string> numbers={"eins","dos", "three", "quatre"};
    cout << accumulate(numbers.begin(), numbers.end(), 0L, 
                       [](size_t sum, string s) {return sum+s.size();});

My apologies for the invalid bugreport.

Reply via email to