[libcxx-commits] [libcxx] c19d8f9 - [libc++] [test] Use sized_sentinel<int*> in range.prim/ssize.pass.cpp.

Arthur O'Dwyer via libcxx-commits libcxx-commits at lists.llvm.org
Wed Dec 8 13:41:31 PST 2021


Author: Arthur O'Dwyer
Date: 2021-12-08T16:41:02-05:00
New Revision: c19d8f955ac3a807978c199fdc4262680d3ad5b2

URL: https://github.com/llvm/llvm-project/commit/c19d8f955ac3a807978c199fdc4262680d3ad5b2
DIFF: https://github.com/llvm/llvm-project/commit/c19d8f955ac3a807978c199fdc4262680d3ad5b2.diff

LOG: [libc++] [test] Use sized_sentinel<int*> in range.prim/ssize.pass.cpp.

Reviewed as part of D115272.

Added: 
    

Modified: 
    libcxx/test/std/ranges/range.access/range.prim/ssize.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/ranges/range.access/range.prim/ssize.pass.cpp b/libcxx/test/std/ranges/range.access/range.prim/ssize.pass.cpp
index d8cee6e5c945a..beedcfa9908bb 100644
--- a/libcxx/test/std/ranges/range.access/range.prim/ssize.pass.cpp
+++ b/libcxx/test/std/ranges/range.access/range.prim/ssize.pass.cpp
@@ -30,8 +30,7 @@ static_assert(std::semiregular<std::remove_cv_t<RangeSSizeT>>);
 struct SizeMember {
   constexpr size_t size() { return 42; }
 };
-
-static_assert(!std::is_invocable_v<RangeSSizeT, const SizeMember>);
+static_assert(!std::is_invocable_v<decltype(std::ranges::ssize), const SizeMember&>);
 
 struct SizeFunction {
   friend constexpr size_t size(SizeFunction) { return 42; }
@@ -41,18 +40,12 @@ struct SizeFunctionSigned {
   friend constexpr std::ptr
diff _t size(SizeFunctionSigned) { return 42; }
 };
 
-struct sentinel {
-  bool operator==(std::input_or_output_iterator auto) const { return true; }
-};
-
-struct RandomAccesslRange {
-  constexpr random_access_iterator<int*> begin() { return {}; }
-  constexpr sentinel end() { return {}; }
+struct SizedSentinelRange {
+  int data_[2] = {};
+  constexpr int *begin() { return data_; }
+  constexpr auto end() { return sized_sentinel<int*>(data_ + 2); }
 };
 
-constexpr std::ptr
diff _t operator-(const sentinel, const random_access_iterator<int*>) { return 2; }
-constexpr std::ptr
diff _t operator-(const random_access_iterator<int*>, const sentinel) { return 2; }
-
 struct ShortUnsignedReturnType {
   constexpr unsigned short size() { return 42; }
 };
@@ -75,7 +68,7 @@ constexpr bool test() {
   assert(std::ranges::ssize(SizeFunctionSigned()) == 42);
   ASSERT_SAME_TYPE(decltype(std::ranges::ssize(SizeFunctionSigned())), std::ptr
diff _t);
 
-  RandomAccesslRange b;
+  SizedSentinelRange b;
   assert(std::ranges::ssize(b) == 2);
   ASSERT_SAME_TYPE(decltype(std::ranges::ssize(b)), std::ptr
diff _t);
 


        


More information about the libcxx-commits mailing list