[libcxx-commits] [PATCH] D111925: [libc++][NFC] Mark LWG3573 as complete

Joe Loser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Oct 15 20:31:13 PDT 2021


jloser created this revision.
jloser added reviewers: ldionne, Quuxplusone, Mordante.
jloser requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

Mark LWG3573 as complete. It involves a change in wording around when
`basic_string_view`'s constructor for iterator/sentinel can throw. The
current implementation is not marked conditionally `noexcept`, so there
is nothing to do here. Add a test that binds this behavior to verify the
constructor is not marked `noexcept(true)` when `end - begin` throws.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111925

Files:
  libcxx/docs/Status/Cxx2bIssues.csv
  libcxx/test/std/strings/string.view/string.view.cons/from_iterator_sentinel.pass.cpp


Index: libcxx/test/std/strings/string.view/string.view.cons/from_iterator_sentinel.pass.cpp
===================================================================
--- libcxx/test/std/strings/string.view/string.view.cons/from_iterator_sentinel.pass.cpp
+++ libcxx/test/std/strings/string.view/string.view.cons/from_iterator_sentinel.pass.cpp
@@ -16,6 +16,7 @@
 
 #include <string_view>
 #include <cassert>
+#include <iterator>
 #include <ranges>
 
 #include "make_string.h"
@@ -43,6 +44,28 @@
   return true;
 }
 
+template <std::input_or_output_iterator I>
+struct throwing_sized_sentinel : public sized_sentinel<I> {
+  using sized_sentinel<I>::sized_sentinel;
+};
+
+template <std::input_or_output_iterator I>
+constexpr std::iter_difference_t<I> operator-(throwing_sized_sentinel<I>, std::input_or_output_iterator auto) {
+  throw std::runtime_error("LWG 3573");
+  return {};
+}
+
+template <class CharT, class Sentinel>
+constexpr bool test_noexcept() {
+  auto val = MAKE_STRING_VIEW(CharT, "test");
+  try {
+    auto sv = std::basic_string_view<CharT>(val.begin(), Sentinel(val.end()));
+  } catch (const std::runtime_error&) {
+    return true;
+  }
+  return false;
+}
+
 static_assert( std::is_constructible_v<std::string_view, const char*, char*>);
 static_assert( std::is_constructible_v<std::string_view, char*, const char*>);
 static_assert(!std::is_constructible_v<std::string_view, char*, void*>);               // not a sentinel
@@ -54,6 +77,8 @@
   test();
   static_assert(test());
 
+  assert((test_noexcept<char, throwing_sized_sentinel<const char*>>()));
+
   return 0;
 }
 
Index: libcxx/docs/Status/Cxx2bIssues.csv
===================================================================
--- libcxx/docs/Status/Cxx2bIssues.csv
+++ libcxx/docs/Status/Cxx2bIssues.csv
@@ -125,7 +125,7 @@
 `3570 <https://wg21.link/LWG3570>`__,"``basic_osyncstream::emit`` should be an unformatted output function","October 2021","",""
 `3571 <https://wg21.link/LWG3571>`__,"``flush_emit`` should set ``badbit`` if the ``emit`` call fails","October 2021","",""
 `3572 <https://wg21.link/LWG3572>`__,"``copyable-box`` should be fully ``constexpr``","October 2021","",""
-`3573 <https://wg21.link/LWG3573>`__,"Missing Throws element for ``basic_string_view(It begin, End end)``","October 2021","",""
+`3573 <https://wg21.link/LWG3573>`__,"Missing Throws element for ``basic_string_view(It begin, End end)``","October 2021","|Complete|","14.0"
 `3574 <https://wg21.link/LWG3574>`__,"``common_iterator`` should be completely ``constexpr``-able","October 2021","",""
 `3580 <https://wg21.link/LWG3580>`__,"``iota_view``'s ``iterator``'s binary ``operator+`` should be improved","October 2021","",""
 `3581 <https://wg21.link/LWG3581>`__,"The range constructor makes ``basic_string_view`` not trivially move constructible","October 2021","",""


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111925.380139.patch
Type: text/x-patch
Size: 2835 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211016/8b1e106a/attachment.bin>


More information about the libcxx-commits mailing list