[libcxx-commits] [PATCH] D115838: [libc++] [ranges] Remove the static_assert from ranges::begin and ranges::end.

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Dec 15 19:16:56 PST 2021


Quuxplusone created this revision.
Quuxplusone added reviewers: ldionne, 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++.

  As discussed offline today with ldionne. The problem with this static_assert
  is that it makes ranges::begin a pitfall for anyone ever to use
  inside a constraint or decltype. Many Ranges things, such as ranges::size,
  are specified as "Does X if X is well-formed, or else Y if Y is well-formed,
  or else `ranges::end(t) - ranges::begin(t)` if that is well-formed, or else..."
  And if there's a static_assert hidden inside `ranges::begin(t)`, then you get
  a hard error as soon as you ask the question -- even if the answer would have
  been "no, that's not well-formed"!
  
  All of the new test cases are mandatory behavior, as far as I'm aware.
  I've removed the tests for the IFNDR cases in ranges::begin and ranges::end.
  The similar tests for ranges::empty and ranges::data were simply wrong, AFAIK.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115838

Files:
  libcxx/include/__ranges/access.h
  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/range.prim/empty.incomplete.verify.cpp
  libcxx/test/std/ranges/range.access/range.access.begin/begin.pass.cpp
  libcxx/test/std/ranges/range.access/range.access.end/end.pass.cpp
  libcxx/test/std/ranges/range.access/range.prim/empty.pass.cpp
  libcxx/test/std/ranges/range.access/range.prim/size.pass.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115838.394723.patch
Type: text/x-patch
Size: 16529 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211216/d64cfe3a/attachment-0001.bin>


More information about the libcxx-commits mailing list