C++ Logo

std-proposals

Advanced search

[std-proposals] Ambiguity or defect with parallel STL algorithms?

From: Brook Milligan <brook_at_[hidden]>
Date: Thu, 24 Feb 2022 21:27:02 -0700
To my reading, documentation on the parallel STL algorithms (e.g., https://en.cppreference.com/w/cpp/algorithm/for_each) clearly indicate that the execution policy argument is taken with a forwarding reference, which would seem to imply that either an lvalue or rvalue would be legitimate arguments. However, at least libstdc++ shipped with gcc 10.3.0 requires only an lvalue as an argument. This seems like a defect in the library, but perhaps I am misunderstanding.

To make this more specific, I have attached a small program that demonstrates the error for me. While both overload [1] and overload [2] with an lvalue execution policy compile, overload [2] with an rvalue execution policy does not compile.

I would greatly appreciate understanding why this behavior is intended and implied by the documentation, or whether this is in fact a defect.

Thanks a lot for your help.

Cheers,
Brook


Received on 2022-02-25 04:27:05