[libcxx-commits] [libcxx] Fixed shared_ptr comparisons with nullptr_t when spaceship is unavailable. (PR #76781)

James Touton via libcxx-commits libcxx-commits at lists.llvm.org
Sun Jan 7 13:46:41 PST 2024


================
@@ -87,5 +87,38 @@ int main(int, char**)
   assert((nullptr <=> p2) == std::strong_ordering::equivalent);
 #endif
 
+#if TEST_STD_VER > 14
+  const std::shared_ptr<int[]> p3(new int[1]);
+  assert(!(p3 == nullptr));
+  assert(!(nullptr == p3));
+  assert(!(p3 < nullptr));
+  assert((nullptr < p3));
+  assert(!(p3 <= nullptr));
+  assert((nullptr <= p3));
+  assert((p3 > nullptr));
+  assert(!(nullptr > p3));
+  assert((p3 >= nullptr));
+  assert(!(nullptr >= p3));
+#  if TEST_STD_VER > 17
+  assert((nullptr <=> p3) == std::strong_ordering::less);
+  assert((p3 <=> nullptr) == std::strong_ordering::greater);
+#  endif
+
+  const std::shared_ptr<int[]> p4;
+  assert((p4 == nullptr));
+  assert((nullptr == p4));
+  assert(!(p4 < nullptr));
+  assert(!(nullptr < p4));
+  assert((p4 <= nullptr));
+  assert((nullptr <= p4));
+  assert(!(p4 > nullptr));
+  assert(!(nullptr > p4));
+  assert((p4 >= nullptr));
+  assert((nullptr >= p4));
+#  if TEST_STD_VER > 17
+  assert((nullptr <=> p4) == std::strong_ordering::equivalent);
----------------
Bekenn wrote:

Updated.

https://github.com/llvm/llvm-project/pull/76781


More information about the libcxx-commits mailing list