[libcxx-commits] [PATCH] D115658: [libc++] Fix the noexceptness of __decay_copy.

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Dec 13 14:58:14 PST 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG4dd901f4d3aa: [libc++] Fix the noexceptness of __decay_copy. (authored by arthur.j.odwyer).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115658/new/

https://reviews.llvm.org/D115658

Files:
  libcxx/include/__utility/decay_copy.h
  libcxx/test/std/ranges/range.access/range.access.begin/begin.pass.cpp
  libcxx/test/std/ranges/range.access/range.access.end/end.pass.cpp


Index: libcxx/test/std/ranges/range.access/range.access.end/end.pass.cpp
===================================================================
--- libcxx/test/std/ranges/range.access/range.access.end/end.pass.cpp
+++ libcxx/test/std/ranges/range.access/range.access.end/end.pass.cpp
@@ -298,6 +298,13 @@
 ASSERT_NOT_NOEXCEPT(std::ranges::end(std::declval<NoThrowADLEnd<ThrowingIterator<int>>&>()));
 ASSERT_NOT_NOEXCEPT(std::ranges::cend(std::declval<NoThrowADLEnd<ThrowingIterator<int>>&>()));
 
+struct BeginReturnsArrayRef {
+    auto begin() const noexcept -> int(&)[10];
+    auto end() const noexcept -> int(&)[10];
+} brar;
+static_assert(noexcept(std::ranges::end(brar)));
+static_assert(noexcept(std::ranges::cend(brar)));
+
 
 int main(int, char**) {
   testArray();
Index: libcxx/test/std/ranges/range.access/range.access.begin/begin.pass.cpp
===================================================================
--- libcxx/test/std/ranges/range.access/range.access.begin/begin.pass.cpp
+++ libcxx/test/std/ranges/range.access/range.access.begin/begin.pass.cpp
@@ -264,6 +264,13 @@
 ASSERT_NOT_NOEXCEPT(std::ranges::begin(std::declval<NoThrowADLBegin<ThrowingIterator<int>>&>()));
 ASSERT_NOT_NOEXCEPT(std::ranges::cbegin(std::declval<NoThrowADLBegin<ThrowingIterator<int>>&>()));
 
+struct BeginReturnsArrayRef {
+    auto begin() const noexcept -> int(&)[10];
+    auto end() const noexcept -> int(&)[10];
+} brar;
+static_assert(noexcept(std::ranges::begin(brar)));
+static_assert(noexcept(std::ranges::cbegin(brar)));
+
 
 int main(int, char**) {
   testArray();
Index: libcxx/include/__utility/decay_copy.h
===================================================================
--- libcxx/include/__utility/decay_copy.h
+++ libcxx/include/__utility/decay_copy.h
@@ -24,7 +24,7 @@
 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
 typename decay<_Tp>::type __decay_copy(_Tp&& __t)
 #if _LIBCPP_STD_VER > 17
-    noexcept(is_nothrow_convertible_v<_Tp, remove_reference_t<_Tp>>)
+    noexcept(is_nothrow_convertible_v<_Tp, decay_t<_Tp>>)
 #endif
 {
   return _VSTD::forward<_Tp>(__t);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115658.394064.patch
Type: text/x-patch
Size: 2083 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211213/ceaf667a/attachment.bin>


More information about the libcxx-commits mailing list