[libcxx-commits] [PATCH] D80452: [libc++] Complete overhaul of constexpr support in std::array
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri May 22 12:52:42 PDT 2020
ldionne created this revision.
Herald added subscribers: libcxx-commits, arphaman, dexonsmith, jkorous.
Herald added a project: libc++.
Herald added a reviewer: libc++.
ldionne added a reviewer: zoecarver.
ldionne added a comment.
I know there's been discussion before about having to return `nullptr` from `begin()` and `end()` for empty arrays and we didn't want to do it. However, doing so is a valid implementation strategy with the given Standard IIUC, and it would only become incorrect if we adopted https://wg21.link/LWG2157. Given that LWG2157 hasn't made it through yet, I think it's a lot more important to fix the situation of `std::array` in libc++ than implement a maybe-future LWG issue resolution.
Also note that if LWG goes through, there's presumably a way to implement it, so we can just switch to that. However, I don't think removing `constexpr` for the empty `std::array`s is ever going to happen, because that would be way too inconsistent.
This commit adds missing support for constexpr in std::array under all
standard modes up to and including C++20. It also transforms the <array>
tests to check for constexpr-friendliness under the right standard modes.
It does change one bit of behavior from the previous array implementation,
notably the fact that begin() and end() on an empty std::array will now
return nullptr. This implementation is allowed by the current wording
for std::array, however if https://wg21.link/LWG2157 goes through, we'll
have to change that strategy for one where different empty arrays have
iterators to different underlying ranges.
Fixes https://llvm.org/PR40124
Fixes rdar://57522096
Supersedes https://reviews.llvm.org/D60666
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D80452
Files:
libcxx/include/array
libcxx/test/std/containers/sequences/array/array.cons/deduct.pass.cpp
libcxx/test/std/containers/sequences/array/array.cons/default.pass.cpp
libcxx/test/std/containers/sequences/array/array.cons/implicit_copy.pass.cpp
libcxx/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp
libcxx/test/std/containers/sequences/array/array.creation/to_array.pass.cpp
libcxx/test/std/containers/sequences/array/array.data/data.pass.cpp
libcxx/test/std/containers/sequences/array/array.data/data_const.pass.cpp
libcxx/test/std/containers/sequences/array/array.fill/fill.pass.cpp
libcxx/test/std/containers/sequences/array/array.size/size.pass.cpp
libcxx/test/std/containers/sequences/array/array.special/swap.pass.cpp
libcxx/test/std/containers/sequences/array/array.swap/swap.pass.cpp
libcxx/test/std/containers/sequences/array/array.tuple/get.pass.cpp
libcxx/test/std/containers/sequences/array/array.tuple/get_const.pass.cpp
libcxx/test/std/containers/sequences/array/array.tuple/get_const_rv.pass.cpp
libcxx/test/std/containers/sequences/array/array.tuple/get_rv.pass.cpp
libcxx/test/std/containers/sequences/array/at.pass.cpp
libcxx/test/std/containers/sequences/array/at_const.pass.cpp
libcxx/test/std/containers/sequences/array/begin.pass.cpp
libcxx/test/std/containers/sequences/array/compare.pass.cpp
libcxx/test/std/containers/sequences/array/contiguous.pass.cpp
libcxx/test/std/containers/sequences/array/empty.pass.cpp
libcxx/test/std/containers/sequences/array/front_back.pass.cpp
libcxx/test/std/containers/sequences/array/front_back_const.pass.cpp
libcxx/test/std/containers/sequences/array/indexing.pass.cpp
libcxx/test/std/containers/sequences/array/indexing_const.pass.cpp
libcxx/test/std/containers/sequences/array/iterators.pass.cpp
libcxx/test/std/containers/sequences/array/max_size.pass.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80452.265783.patch
Type: text/x-patch
Size: 77287 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200522/71ba6a08/attachment-0001.bin>
More information about the libcxx-commits
mailing list