[llvm-branch-commits] [libcxx] 0e0fc06 - [libc++] Mark LWG2166 as "Nothing To Do" (#236422)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Nov 11 01:51:56 PST 2026


Author: Lucas Mellone
Date: 2026-11-11T11:11:32+08:00
New Revision: 0e0fc06544bff8765eb09a38f606f8537d2aee67

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

LOG: [libc++] Mark LWG2166 as "Nothing To Do" (#236422)

LWG2166 formalised the binary heap layout such that `for 0 < i < N`,
`comp(a[(i-1)/2], a[i])` is `false`. libc++’s heap algorithms already
implement this layout, so this patch is NFC and mainly adding test
coverage for heap property.

Closes: https://github.com/llvm/llvm-project/issues/99969

---------

Co-authored-by: A. Jiang <de34 at live.cn>

Added: 
    libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/heap_helpers.h

Modified: 
    libcxx/docs/Status/Cxx17Issues.csv
    libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until.pass.cpp
    libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until_comp.pass.cpp
    libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/ranges_is_heap_until.pass.cpp
    libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp
    libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp
    libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/ranges_make_heap.pass.cpp
    libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp
    libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp
    libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/ranges_pop_heap.pass.cpp
    libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp
    libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp
    libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/ranges_push_heap.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/docs/Status/Cxx17Issues.csv b/libcxx/docs/Status/Cxx17Issues.csv
index a642284d5cc3ac..b96dff456c789d 100644
--- a/libcxx/docs/Status/Cxx17Issues.csv
+++ b/libcxx/docs/Status/Cxx17Issues.csv
@@ -181,7 +181,7 @@
 "`LWG2728 <https://wg21.link/LWG2728>`__","status(p).permissions() and symlink_status(p).permissions() are not specified","2016-06 (Oulu)","|Complete|","","`#103430 <https://github.com/llvm/llvm-project/issues/103430>`__",""
 "","","","","","",""
 "`LWG2062 <https://wg21.link/LWG2062>`__","Effect contradictions w/o no-throw guarantee of std::function swaps","2016-11 (Issaquah)","|Complete|","","`#103431 <https://github.com/llvm/llvm-project/issues/103431>`__",""
-"`LWG2166 <https://wg21.link/LWG2166>`__","Heap property underspecified?","2016-11 (Issaquah)","","","`#99969 <https://github.com/llvm/llvm-project/issues/99969>`__",""
+"`LWG2166 <https://wg21.link/LWG2166>`__","Heap property underspecified?","2016-11 (Issaquah)","|Nothing To Do|","","`#99969 <https://github.com/llvm/llvm-project/issues/99969>`__",""
 "`LWG2221 <https://wg21.link/LWG2221>`__","No formatted output operator for nullptr","2016-11 (Issaquah)","|Complete|","","`#103432 <https://github.com/llvm/llvm-project/issues/103432>`__",""
 "`LWG2223 <https://wg21.link/LWG2223>`__","shrink_to_fit effect on iterator validity","2016-11 (Issaquah)","|Complete|","","`#103433 <https://github.com/llvm/llvm-project/issues/103433>`__",""
 "`LWG2261 <https://wg21.link/LWG2261>`__","Are containers required to use their 'pointer' type internally?","2016-11 (Issaquah)","","","`#99970 <https://github.com/llvm/llvm-project/issues/99970>`__",""

diff  --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/heap_helpers.h b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/heap_helpers.h
new file mode 100644
index 00000000000000..edeaeaa3372d85
--- /dev/null
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/heap_helpers.h
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+#include <functional>
+#include <iterator>
+
+#include "test_macros.h"
+
+// LWG2166: Heap property underspecified?
+// [alg.heap.operations]/1: With N = b - a, for all i, 0 < i < N,
+// bool(comp(a[floor((i - 1) / 2)], a[i])) is false.
+template <class Iter, class Comp = std::less<typename std::iterator_traits<Iter>::value_type> >
+TEST_CONSTEXPR_CXX20 bool satisfies_heap_property(Iter a, Iter b, Comp cmp = Comp()) {
+  typedef typename std::iterator_traits<Iter>::
diff erence_type 
diff erence_type;
+  const 
diff erence_type n = b - a;
+  for (
diff erence_type i = 1; i < n; ++i)
+    if (cmp(a[(i - 1) / 2], a[i]))
+      return false;
+  return true;
+}

diff  --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until.pass.cpp
index 78465465e5eb49..573f681c8d2703 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until.pass.cpp
@@ -17,6 +17,7 @@
 #include <cassert>
 #include <iterator>
 
+#include "../heap_helpers.h"
 #include "test_macros.h"
 #include "test_iterators.h"
 
@@ -24,6 +25,13 @@
 TEST_CONSTEXPR bool test_constexpr() {
     int ia[] = {0, 0, 0, 0, 1, 0};
     int ib[] = {0, 0, 0, 1, 1, 1};
+
+    assert(!satisfies_heap_property(std::begin(ia), std::end(ia)));
+    assert(!satisfies_heap_property(std::begin(ib), std::end(ib)));
+
+    assert(satisfies_heap_property(std::begin(ia), ia + 4));
+    assert(satisfies_heap_property(std::begin(ib), ib + 3));
+
     return    (std::is_heap_until(std::begin(ia), std::end(ia)) == ia+4)
            && (std::is_heap_until(std::begin(ib), std::end(ib)) == ib+3);
     }

diff  --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until_comp.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until_comp.pass.cpp
index 15e481807eb6c0..6cdbcb29a9c9db 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until_comp.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until_comp.pass.cpp
@@ -18,6 +18,7 @@
 #include <functional>
 #include <iterator>
 
+#include "../heap_helpers.h"
 #include "test_macros.h"
 #include "test_iterators.h"
 
@@ -25,6 +26,16 @@
 TEST_CONSTEXPR bool test_constexpr() {
     int ia[] = {1, 0, 0, 0};
     int ib[] = {0, 1, 1, 0};
+
+    assert(!satisfies_heap_property(std::begin(ia), std::end(ia), std::greater<int>()));
+    assert(!satisfies_heap_property(std::begin(ib), std::end(ib), std::greater<int>()));
+
+    assert(satisfies_heap_property(std::begin(ia), ia + 1, std::greater<int>()));
+    assert(!satisfies_heap_property(std::begin(ia), ia + 2, std::greater<int>()));
+
+    assert(satisfies_heap_property(std::begin(ib), ib + 3, std::greater<int>()));
+    assert(!satisfies_heap_property(std::begin(ib), ib + 4, std::greater<int>()));
+
     return    (std::is_heap_until(std::begin(ia), std::end(ia), std::greater<int>()) == ia+1)
            && (std::is_heap_until(std::begin(ib), std::end(ib), std::greater<int>()) == ib+3);
     }

diff  --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/ranges_is_heap_until.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/ranges_is_heap_until.pass.cpp
index 42a66fa5723d65..ea9588d7017bea 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/ranges_is_heap_until.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/ranges_is_heap_until.pass.cpp
@@ -26,6 +26,7 @@
 #include <functional>
 #include <ranges>
 
+#include "../heap_helpers.h"
 #include "almost_satisfies_types.h"
 #include "test_iterators.h"
 
@@ -81,6 +82,9 @@ constexpr void test_one(std::array<int, N> input, std::size_t until_index) {
   { // (iterator, sentinel) overload.
     std::same_as<Iter> decltype(auto) result = std::ranges::is_heap_until(begin, end);
     assert(base(result) == input.data() + until_index);
+    assert(satisfies_heap_property(input.data(), input.data() + until_index));
+    if (until_index < N)
+      assert(!satisfies_heap_property(input.data(), input.data() + until_index + 1));
   }
 
   { // (range) overload.
@@ -144,6 +148,10 @@ constexpr bool test() {
       assert(result_default_comp == in.begin() + 1);
       auto result_custom_comp = std::ranges::is_heap_until(in.begin(), in.end(), gt);
       assert(result_custom_comp == in.end());
+
+      assert(satisfies_heap_property(in.begin(), in.begin() + 1, ls));
+      assert(!satisfies_heap_property(in.begin(), in.begin() + 2, ls));
+      assert(satisfies_heap_property(in.begin(), in.end(), gt));
     }
 
     { // (range) overload.
@@ -168,6 +176,12 @@ constexpr bool test() {
       assert(result_default_comp == in.begin() + 1);
       auto result_custom_comp = std::ranges::is_heap_until(in.begin(), in.end(), {}, negate);
       assert(result_custom_comp == in.end());
+
+      std::ranges::less ls;
+      auto projected = [&](const A& x, const A& y) { return ls(negate(x), negate(y)); };
+      assert(satisfies_heap_property(in.begin(), in.begin() + 1, ls));
+      assert(!satisfies_heap_property(in.begin(), in.begin() + 2, ls));
+      assert(satisfies_heap_property(in.begin(), in.end(), projected));
     }
 
     { // (range) overload.

diff  --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp
index 26eba620f29248..a5b02579577cc8 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp
@@ -15,10 +15,12 @@
 
 #include <algorithm>
 #include <cassert>
+#include <functional>
 
-#include "test_macros.h"
-#include "test_iterators.h"
+#include "../heap_helpers.h"
 #include "MoveOnly.h"
+#include "test_iterators.h"
+#include "test_macros.h"
 
 template<class T, class Iter>
 TEST_CONSTEXPR_CXX20 bool test()
@@ -29,6 +31,7 @@ TEST_CONSTEXPR_CXX20 bool test()
         std::make_heap(Iter(work), Iter(work+n));
         assert(std::is_heap(work, work+n));
         assert(std::is_permutation(work, work+n, orig));
+        assert(satisfies_heap_property(work, work + n, std::less<T>()));
         std::copy(orig, orig+n, work);
     }
 
@@ -36,6 +39,7 @@ TEST_CONSTEXPR_CXX20 bool test()
         T input[] = {3, 4, 1, 2, 5};
         std::make_heap(Iter(input), Iter(input + 5));
         assert(std::is_heap(input, input + 5));
+        assert(satisfies_heap_property(input, input + 5, std::less<T>()));
         std::pop_heap(input, input + 5); assert(input[4] == 5);
         std::pop_heap(input, input + 4); assert(input[3] == 4);
         std::pop_heap(input, input + 3); assert(input[2] == 3);

diff  --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp
index bfdbf184a00cb7..8ca5be662e2684 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp
@@ -17,9 +17,10 @@
 #include <cassert>
 #include <functional>
 
-#include "test_macros.h"
-#include "test_iterators.h"
+#include "../heap_helpers.h"
 #include "MoveOnly.h"
+#include "test_iterators.h"
+#include "test_macros.h"
 
 template<class T, class Iter>
 TEST_CONSTEXPR_CXX20 bool test()
@@ -29,6 +30,7 @@ TEST_CONSTEXPR_CXX20 bool test()
     for (int n = 0; n < 15; ++n) {
         std::make_heap(Iter(work), Iter(work+n), std::greater<T>());
         assert(std::is_heap(work, work+n, std::greater<T>()));
+        assert(satisfies_heap_property(work, work + n, std::greater<T>()));
         assert(std::is_permutation(work, work+n, orig));
         std::copy(orig, orig+n, work);
     }
@@ -37,6 +39,7 @@ TEST_CONSTEXPR_CXX20 bool test()
         T input[] = {3, 4, 1, 2, 5};
         std::make_heap(Iter(input), Iter(input + 5), std::greater<T>());
         assert(std::is_heap(input, input + 5, std::greater<T>()));
+        assert(satisfies_heap_property(input, input + 5, std::greater<T>()));
         std::pop_heap(input, input + 5, std::greater<T>()); assert(input[4] == 1);
         std::pop_heap(input, input + 4, std::greater<T>()); assert(input[3] == 2);
         std::pop_heap(input, input + 3, std::greater<T>()); assert(input[2] == 3);

diff  --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/ranges_make_heap.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/ranges_make_heap.pass.cpp
index 2c96c1987a1212..39a697288a5a7b 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/ranges_make_heap.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/ranges_make_heap.pass.cpp
@@ -30,6 +30,7 @@
 #include <ranges>
 
 #include "almost_satisfies_types.h"
+#include "../heap_helpers.h"
 #include "test_iterators.h"
 
 // SFINAE tests.
@@ -64,6 +65,7 @@ constexpr void verify_heap(const std::array<T, N>& heapified, Iter last, std::ar
   assert(heapified == expected);
   assert(std::to_address(base(last)) == heapified.data() + heapified.size());
   assert(std::is_heap(heapified.begin(), heapified.end()));
+  assert(satisfies_heap_property(heapified.begin(), heapified.end()));
 }
 
 template <class Iter, class Sent, std::size_t N>

diff  --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp
index d06ddfc0f127b2..82431e55e8f269 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp
@@ -17,6 +17,7 @@
 #include <cassert>
 #include <functional>
 
+#include "../heap_helpers.h"
 #include "test_macros.h"
 #include "test_iterators.h"
 #include "MoveOnly.h"
@@ -30,6 +31,7 @@ TEST_CONSTEXPR_CXX20 bool test()
     for (int i = 15; i >= 1; --i) {
         std::pop_heap(Iter(work), Iter(work+i));
         assert(std::is_heap(work, work+i-1));
+        assert(satisfies_heap_property(work, work + i - 1));
         assert(std::max_element(work, work+i-1) == work);
         assert(std::is_permutation(work, work+15, orig));
     }
@@ -38,6 +40,7 @@ TEST_CONSTEXPR_CXX20 bool test()
     {
         T input[] = {5, 4, 1, 2, 3};
         assert(std::is_heap(input, input + 5));
+        assert(satisfies_heap_property(input, input + 5));
         std::pop_heap(Iter(input), Iter(input + 5)); assert(input[4] == 5);
         std::pop_heap(Iter(input), Iter(input + 4)); assert(input[3] == 4);
         std::pop_heap(Iter(input), Iter(input + 3)); assert(input[2] == 3);

diff  --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp
index d080152e29d164..cfe8c379a8c2a7 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp
@@ -17,9 +17,10 @@
 #include <cassert>
 #include <functional>
 
-#include "test_macros.h"
-#include "test_iterators.h"
+#include "../heap_helpers.h"
 #include "MoveOnly.h"
+#include "test_iterators.h"
+#include "test_macros.h"
 
 template<class T, class Iter>
 TEST_CONSTEXPR_CXX20 bool test()
@@ -30,6 +31,7 @@ TEST_CONSTEXPR_CXX20 bool test()
     for (int i = 15; i >= 1; --i) {
         std::pop_heap(Iter(work), Iter(work+i), std::greater<T>());
         assert(std::is_heap(work, work+i-1, std::greater<T>()));
+        assert(satisfies_heap_property(work, work + i - 1, std::greater<T>()));
         assert(std::min_element(work, work+i-1) == work);
         assert(std::is_permutation(work, work+15, orig));
     }
@@ -38,6 +40,7 @@ TEST_CONSTEXPR_CXX20 bool test()
     {
         T input[] = {1, 2, 5, 4, 3};
         assert(std::is_heap(input, input + 5, std::greater<T>()));
+        assert(satisfies_heap_property(input, input + 5, std::greater<T>()));
         std::pop_heap(Iter(input), Iter(input + 5), std::greater<T>()); assert(input[4] == 1);
         std::pop_heap(Iter(input), Iter(input + 4), std::greater<T>()); assert(input[3] == 2);
         std::pop_heap(Iter(input), Iter(input + 3), std::greater<T>()); assert(input[2] == 3);

diff  --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/ranges_pop_heap.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/ranges_pop_heap.pass.cpp
index b0a00335ab4402..db6f0641228992 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/ranges_pop_heap.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/ranges_pop_heap.pass.cpp
@@ -29,6 +29,7 @@
 #include <memory>
 #include <ranges>
 
+#include "../heap_helpers.h"
 #include "almost_satisfies_types.h"
 #include "test_iterators.h"
 
@@ -65,6 +66,7 @@ constexpr void verify_heap(const std::array<T, N>& heapified, Iter last, std::ar
   assert(std::to_address(base(last)) == heapified.data() + heapified.size());
   assert(std::is_heap(heapified.begin(), heapified.end() - 1));
   assert(*std::max_element(heapified.begin(), heapified.end()) == heapified.back());
+  assert(satisfies_heap_property(heapified.begin(), heapified.end() - 1));
 }
 
 template <class Iter, class Sent, std::size_t N>

diff  --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp
index 9c3f787148542a..441e0ca3a2d183 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp
@@ -17,9 +17,10 @@
 #include <cassert>
 #include <functional>
 
-#include "test_macros.h"
-#include "test_iterators.h"
+#include "../heap_helpers.h"
 #include "MoveOnly.h"
+#include "test_iterators.h"
+#include "test_macros.h"
 
 template<class T, class Iter>
 TEST_CONSTEXPR_CXX20 bool test()
@@ -30,6 +31,7 @@ TEST_CONSTEXPR_CXX20 bool test()
         std::push_heap(Iter(work), Iter(work+i));
         assert(std::is_permutation(work, work+i, orig));
         assert(std::is_heap(work, work+i));
+        assert(satisfies_heap_property(work, work + i));
     }
 
     {
@@ -40,6 +42,7 @@ TEST_CONSTEXPR_CXX20 bool test()
         std::push_heap(Iter(input), Iter(input + 4)); assert(input[0] == 5);
         std::push_heap(Iter(input), Iter(input + 5)); assert(input[0] == 5);
         assert(std::is_heap(input, input + 5));
+        assert(satisfies_heap_property(input, input + 5));
     }
     return true;
 }

diff  --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp
index 1fdfe3ddade895..d7e3d149ce104f 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp
@@ -17,9 +17,10 @@
 #include <cassert>
 #include <functional>
 
-#include "test_macros.h"
-#include "test_iterators.h"
+#include "../heap_helpers.h"
 #include "MoveOnly.h"
+#include "test_iterators.h"
+#include "test_macros.h"
 
 template<class T, class Iter>
 TEST_CONSTEXPR_CXX20 bool test()
@@ -30,6 +31,7 @@ TEST_CONSTEXPR_CXX20 bool test()
         std::push_heap(Iter(work), Iter(work+i), std::greater<T>());
         assert(std::is_permutation(work, work+i, orig));
         assert(std::is_heap(work, work+i, std::greater<T>()));
+        assert(satisfies_heap_property(work, work + i, std::greater<T>()));
     }
 
     {
@@ -40,6 +42,7 @@ TEST_CONSTEXPR_CXX20 bool test()
         std::push_heap(Iter(input), Iter(input + 4), std::greater<T>()); assert(input[0] == 1);
         std::push_heap(Iter(input), Iter(input + 5), std::greater<T>()); assert(input[0] == 1);
         assert(std::is_heap(input, input + 5, std::greater<T>()));
+        assert(satisfies_heap_property(input, input + 5, std::greater<T>()));
     }
     return true;
 }

diff  --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/ranges_push_heap.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/ranges_push_heap.pass.cpp
index 7161e6138487d3..5f253cf9f5abaf 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/ranges_push_heap.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/ranges_push_heap.pass.cpp
@@ -29,6 +29,7 @@
 #include <memory>
 #include <ranges>
 
+#include "../heap_helpers.h"
 #include "almost_satisfies_types.h"
 #include "test_iterators.h"
 
@@ -64,6 +65,7 @@ constexpr void verify_heap(const std::array<T, N>& heapified, Iter last, std::ar
   assert(heapified == expected);
   assert(std::to_address(base(last)) == heapified.data() + heapified.size());
   assert(std::is_heap(heapified.begin(), heapified.end()));
+  assert(satisfies_heap_property(heapified.begin(), heapified.end()));
 }
 
 template <class Iter, class Sent, std::size_t N>


        


More information about the llvm-branch-commits mailing list