[libcxx-commits] [PATCH] D115607: [libc++] [ranges] Improve ranges::{begin, end, cbegin, cend, data, size, ssize}

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun Dec 12 19:04:32 PST 2021


Quuxplusone created this revision.
Quuxplusone added reviewers: ldionne, jloser, var-const, libc++.
Quuxplusone added a project: libc++.
Quuxplusone requested review of this revision.
Herald added a subscriber: libcxx-commits.
Herald added 1 blocking reviewer(s): libc++.

This follows on from D115312 <https://reviews.llvm.org/D115312>, making all our other CPOs follow the same pattern. In the process I found and fixed several conformance bugs (and probably fixed several more //without// finding them):

  auto a = std::ranges::cbegin(std::string_view("x"));  // should be OK
  auto b = std::ranges::cend(std::string_view("x"));  // should be OK
  struct Foo { int size() &; };
  int c = std::ranges::size(Foo());  // should be OK
  struct Incomplete;
  static_assert(not std::ranges::sized_range<Foo[]>);  // should be OK

I'm aware that the tests for all of these CPOs are bad, but I have no immediate plans to refactor them; I just added the "obviously" missing coverage for cbegin and cend, and added/corrected regression tests for the bugs mentioned above.

If this looks good, the next step would be for me to implement the missing CPOs — `cdata`, `rbegin`, `rend`, `crbegin`, `crend` — along these same lines. I propose to split `access.h` into `begin.h` (begin/cbegin) and `end.h` (end/cend); introduce `rbegin.h` (rbegin/crbegin) and `rend.h` (rend/crend); and add cdata to the existing `data.h`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115607

Files:
  libcxx/include/__ranges/access.h
  libcxx/include/__ranges/data.h
  libcxx/include/__ranges/size.h
  libcxx/test/libcxx/ranges/range.access/begin.verify.cpp
  libcxx/test/libcxx/ranges/range.access/cbegin.verify.cpp
  libcxx/test/libcxx/ranges/range.access/cend.verify.cpp
  libcxx/test/libcxx/ranges/range.access/data.verify.cpp
  libcxx/test/libcxx/ranges/range.access/end.verify.cpp
  libcxx/test/libcxx/ranges/range.access/range.access.begin/incomplete.verify.cpp
  libcxx/test/libcxx/ranges/range.access/range.access.cbegin/incomplete.verify.cpp
  libcxx/test/libcxx/ranges/range.access/range.access.cend/incomplete.verify.cpp
  libcxx/test/libcxx/ranges/range.access/range.access.end/incomplete.verify.cpp
  libcxx/test/libcxx/ranges/range.access/range.prim/data.incomplete.verify.cpp
  libcxx/test/libcxx/ranges/range.access/size.verify.cpp
  libcxx/test/libcxx/ranges/range.access/ssize.verify.cpp
  libcxx/test/std/ranges/range.access/begin.pass.cpp
  libcxx/test/std/ranges/range.access/cbegin.compile.pass.cpp
  libcxx/test/std/ranges/range.access/cend.compile.pass.cpp
  libcxx/test/std/ranges/range.access/data.pass.cpp
  libcxx/test/std/ranges/range.access/empty.pass.cpp
  libcxx/test/std/ranges/range.access/end.pass.cpp
  libcxx/test/std/ranges/range.access/range.access.begin/begin.pass.cpp
  libcxx/test/std/ranges/range.access/range.access.cbegin/cbegin.compile.pass.cpp
  libcxx/test/std/ranges/range.access/range.access.cend/cend.compile.pass.cpp
  libcxx/test/std/ranges/range.access/range.access.end/end.pass.cpp
  libcxx/test/std/ranges/range.access/range.prim/data.pass.cpp
  libcxx/test/std/ranges/range.access/range.prim/empty.pass.cpp
  libcxx/test/std/ranges/range.access/range.prim/size.pass.cpp
  libcxx/test/std/ranges/range.access/range.prim/ssize.pass.cpp
  libcxx/test/std/ranges/range.access/size.pass.cpp
  libcxx/test/std/ranges/range.access/ssize.pass.cpp
  libcxx/test/std/ranges/range.req/range.sized/sized_range.compile.pass.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115607.393791.patch
Type: text/x-patch
Size: 48662 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211213/69b4e3a4/attachment-0001.bin>


More information about the libcxx-commits mailing list