CppCoreGuidelines icon indicating copy to clipboard operation
CppCoreGuidelines copied to clipboard

P.3 needs to be updated now the Ranges TS is part of the standard

Open louwers opened this issue 3 years ago • 6 comments

I propose that the second example is removed:

for_each(par, v, [](int x) { /* do something with the value of x */ });

as passing an ExecutionPolicy is not possible in the final version

To avoid confusion with (std::)for_each, I would also suggest that ranges::for_each is used.

Related: #1254

louwers avatar Jan 10 '22 22:01 louwers

The intent is still "makes it clear that we are not interested in the order in which the elements of v are handled." - I'd say if we are to downgrade it to standard, it should be for_each(par, begin(v), end(v), [](int x) { ...

cubbimew avatar Jan 10 '22 23:01 cubbimew

for_each(ranges, [](int x) {....

for_each(par, first, last, [](int x) {.... is enough to demonstrate the intent and the syntax is clear.

markyin avatar Jan 11 '22 05:01 markyin

The constrained algos in namespace ranges are not found by ADL so I definitely think it should be qualified as ranges::for_each(v, ...)

jwakely avatar Jan 11 '22 10:01 jwakely

Editors call: Thanks! We like the approach of qualifying the first one with ranges:: and removing the second one that uses par. Also update the reference to the Ranges TS please. Would you submit a PR please?

hsutter avatar Jan 27 '22 21:01 hsutter

There's no rangified parallel algorithms in Ranges TS or even C++20/23... Should we refer to P0836 for these proposed algorithms?

frederick-vs-ja avatar Apr 25 '22 10:04 frederick-vs-ja

I think that paper was ~~abandoned and/or rejected~~ never discussed and seems moribund. P2408 will make many parallel algos usable for views and other ranges.

jwakely avatar Apr 25 '22 11:04 jwakely