[libcxx-commits] [PATCH] D115422: [libc++][ranges] Add subsumption tests to `[special.mem.concepts]`.

Konstantin Varlamov via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Dec 10 21:10:09 PST 2021


var-const updated this revision to Diff 393662.
var-const added a comment.

Rebase on `main`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115422

Files:
  libcxx/test/libcxx/algorithms/specialized.algorithms/special.mem.concepts/nothrow_forward_iterator.compile.pass.cpp
  libcxx/test/libcxx/algorithms/specialized.algorithms/special.mem.concepts/nothrow_forward_range.compile.pass.cpp
  libcxx/test/libcxx/algorithms/specialized.algorithms/special.mem.concepts/nothrow_sentinel_for.compile.pass.cpp


Index: libcxx/test/libcxx/algorithms/specialized.algorithms/special.mem.concepts/nothrow_sentinel_for.compile.pass.cpp
===================================================================
--- libcxx/test/libcxx/algorithms/specialized.algorithms/special.mem.concepts/nothrow_sentinel_for.compile.pass.cpp
+++ libcxx/test/libcxx/algorithms/specialized.algorithms/special.mem.concepts/nothrow_sentinel_for.compile.pass.cpp
@@ -16,3 +16,20 @@
 
 static_assert(std::ranges::__nothrow_sentinel_for<int*, int*>);
 static_assert(!std::ranges::__nothrow_sentinel_for<int*, long*>);
+
+// Because `__nothrow_sentinel_for` is essentially an alias for `sentinel_for`,
+// the two concepts should subsume each other.
+
+constexpr bool ntsf_subsumes_sf(std::ranges::__nothrow_sentinel_for<char*> auto) requires true {
+  return true;
+}
+constexpr bool ntsf_subsumes_sf(std::sentinel_for<char*> auto);
+
+static_assert(ntsf_subsumes_sf("foo"));
+
+constexpr bool sf_subsumes_ntsf(std::sentinel_for<char*> auto) requires true {
+  return true;
+}
+constexpr bool sf_subsumes_ntsf(std::ranges::__nothrow_sentinel_for<char*> auto);
+
+static_assert(sf_subsumes_ntsf("foo"));
Index: libcxx/test/libcxx/algorithms/specialized.algorithms/special.mem.concepts/nothrow_forward_range.compile.pass.cpp
===================================================================
--- libcxx/test/libcxx/algorithms/specialized.algorithms/special.mem.concepts/nothrow_forward_range.compile.pass.cpp
+++ libcxx/test/libcxx/algorithms/specialized.algorithms/special.mem.concepts/nothrow_forward_range.compile.pass.cpp
@@ -33,3 +33,10 @@
 static_assert(!std::ranges::__nothrow_forward_range<test_range<cpp20_input_iterator>>);
 static_assert(std::ranges::forward_range<test_range<ForwardProxyIterator>>);
 static_assert(!std::ranges::__nothrow_forward_range<test_range<ForwardProxyIterator>>);
+
+constexpr bool forward_subsumes_input(std::ranges::__nothrow_forward_range auto&&) {
+  return true;
+}
+constexpr bool forward_subsumes_input(std::ranges::__nothrow_input_range auto&&);
+
+static_assert(forward_subsumes_input("foo"));
Index: libcxx/test/libcxx/algorithms/specialized.algorithms/special.mem.concepts/nothrow_forward_iterator.compile.pass.cpp
===================================================================
--- libcxx/test/libcxx/algorithms/specialized.algorithms/special.mem.concepts/nothrow_forward_iterator.compile.pass.cpp
+++ libcxx/test/libcxx/algorithms/specialized.algorithms/special.mem.concepts/nothrow_forward_iterator.compile.pass.cpp
@@ -29,3 +29,10 @@
 static_assert(std::ranges::__nothrow_forward_iterator<forward_iterator<int*>>);
 static_assert(std::forward_iterator<ForwardProxyIterator>);
 static_assert(!std::ranges::__nothrow_forward_iterator<ForwardProxyIterator>);
+
+constexpr bool forward_subsumes_input(std::ranges::__nothrow_forward_iterator auto) {
+  return true;
+}
+constexpr bool forward_subsumes_input(std::ranges::__nothrow_input_iterator auto);
+
+static_assert(forward_subsumes_input("foo"));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115422.393662.patch
Type: text/x-patch
Size: 3006 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211211/f380e36c/attachment.bin>


More information about the libcxx-commits mailing list