[libcxx-commits] [PATCH] D80790: [libc++] Remove redundant empty specialization in std::array

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri May 29 05:56:45 PDT 2020


ldionne created this revision.
ldionne added a reviewer: zoecarver.
Herald added subscribers: libcxx-commits, dexonsmith, jkorous.
Herald added a project: libc++.
Herald added a reviewer: libc++.
ldionne marked an inline comment as done.
ldionne added inline comments.
ldionne added a reviewer: miscco.


================
Comment at: libcxx/include/array:290
-    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-    iterator end() _NOEXCEPT {return iterator(data());}
-    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
----------------
Careful -- the diff is a bit confusing since it aligns the old specialization of `std::array<T, 0>` with the new `std::array<T, N>` base template. That's why it seems like the old diff was incorrectly implemented as `iterator end() _NOEXCEPT {return iterator(data());}`, when it really was correctly implemented because that was for the empty-array case.


Instead of having two full specializations for std::array, factor the
common code into an helper class. I was careful not to change the
behavior of std::array, especially ABI wise.

The only purposeful functionality change is that when the debug mode is
enabled, accessing a non-empty std::array out-of-bounds will `_LIBCPP_ASSERT`,
which seems like an improvement.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80790

Files:
  libcxx/include/array

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80790.267202.patch
Type: text/x-patch
Size: 13810 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200529/e6abc86a/attachment-0001.bin>


More information about the libcxx-commits mailing list