This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Implement ranges::for_each{, _n}
ClosedPublic

Authored by philnik on Apr 23 2022, 9:25 AM.

Details

Reviewers
Mordante
var-const
Group Reviewers
Restricted Project
Commits
rG80045e9afa2f: [libc++] Implement ranges::for_each{, _n}

Diff Detail

Event Timeline

philnik created this revision.Apr 23 2022, 9:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 23 2022, 9:25 AM
Herald added a subscriber: mgorny. · View Herald Transcript
philnik requested review of this revision.Apr 23 2022, 9:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 23 2022, 9:25 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
var-const requested changes to this revision.Apr 27 2022, 8:15 PM

Looking pretty good, just a few comments.

libcxx/include/__algorithm/ranges_for_each_n.h
51

Nit: move __func as well?

libcxx/include/algorithm
967

Please update the synopsis as well.

libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each.pass.cpp
11

Please add the synopsis.

31

Please also check the indirectly_unary_invocable constraint.

45

Please also check with an empty range.

49

Nit: decltype(auto).

57

Can you also check that it works when the functor is move-only (since the standard mandates that for_each_result should initialize the functor by moving)?

This revision now requires changes to proceed.Apr 27 2022, 8:15 PM
var-const added inline comments.Apr 27 2022, 8:16 PM
libcxx/include/algorithm
967

(note that you'll probably need to add for_each_result to the synopsis)

philnik marked 8 inline comments as done.May 1 2022, 6:27 AM
philnik added inline comments.
libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each.pass.cpp
57

A functor can't be move-only. It's mandated that it's copy-constructible by indirectly_unary_invocable.

philnik updated this revision to Diff 426297.May 1 2022, 6:27 AM
philnik marked an inline comment as done.
  • Rebased
  • Address comments
var-const accepted this revision.May 2 2022, 2:25 PM
var-const added inline comments.
libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each.pass.cpp
57

Thanks for explaining.

101

Nit: s/emptry/empty/.

This revision is now accepted and ready to land.May 2 2022, 2:25 PM

LGTM, thanks!

This revision was automatically updated to reflect the committed changes.
philnik marked an inline comment as done.