[libcxx-commits] [libcxx] r369448 - Fix a couple of unguarded operator, calls in algorithm. Fixes PR#43063. Updated all the heap tests to check this.
Marshall Clow via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Aug 20 14:31:52 PDT 2019
Author: marshall
Date: Tue Aug 20 14:31:51 2019
New Revision: 369448
URL: http://llvm.org/viewvc/llvm-project?rev=369448&view=rev
Log:
Fix a couple of unguarded operator, calls in algorithm. Fixes PR#43063. Updated all the heap tests to check this.
Modified:
libcxx/trunk/include/algorithm
libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap.pass.cpp
libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_comp.pass.cpp
libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until.pass.cpp
libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until_comp.pass.cpp
libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp
libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp
libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp
libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp
libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp
libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp
libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp
libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp
Modified: libcxx/trunk/include/algorithm
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=369448&r1=369447&r2=369448&view=diff
==============================================================================
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Tue Aug 20 14:31:51 2019
@@ -3117,10 +3117,10 @@ _SampleIterator __sample(_PopulationIter
input_iterator_tag) {
_Distance __k = 0;
- for (; __first != __last && __k < __n; ++__first, (void)++__k)
+ for (; __first != __last && __k < __n; ++__first, (void) ++__k)
__output_iter[__k] = *__first;
_Distance __sz = __k;
- for (; __first != __last; ++__first, (void)++__k) {
+ for (; __first != __last; ++__first, (void) ++__k) {
_Distance __r = _VSTD::uniform_int_distribution<_Distance>(0, __k)(__g);
if (__r < __sz)
__output_iter[__r] = *__first;
@@ -3190,7 +3190,7 @@ template<class _RandomAccessIterator, cl
if (__d > 1)
{
_Dp __uid;
- for (--__last, --__d; __first < __last; ++__first, --__d)
+ for (--__last, (void) --__d; __first < __last; ++__first, (void) --__d)
{
difference_type __i = __uid(__g, _Pp(0, __d));
if (__i != difference_type(0))
@@ -3373,7 +3373,7 @@ __stable_partition(_ForwardIterator __fi
// All trues now at start of range, all falses in buffer
// Move falses back into range, but don't mess up __first which points to first false
__i = __first;
- for (value_type* __t2 = __p.first; __t2 < __t; ++__t2, ++__i)
+ for (value_type* __t2 = __p.first; __t2 < __t; ++__t2, (void) ++__i)
*__i = _VSTD::move(*__t2);
// __h destructs moved-from values out of the temp buffer, but doesn't deallocate buffer
return __first;
@@ -3505,7 +3505,7 @@ __stable_partition(_BidirectionalIterato
__i = ++__first;
// All trues now at start of range, all falses in buffer
// Move falses back into range, but don't mess up __first which points to first false
- for (value_type* __t2 = __p.first; __t2 < __t; ++__t2, ++__i)
+ for (value_type* __t2 = __p.first; __t2 < __t; ++__t2, (void) ++__i)
*__i = _VSTD::move(*__t2);
// __h destructs moved-from values out of the temp buffer, but doesn't deallocate buffer
return __first;
@@ -4428,14 +4428,14 @@ __buffered_inplace_merge(_BidirectionalI
if (__len1 <= __len2)
{
value_type* __p = __buff;
- for (_BidirectionalIterator __i = __first; __i != __middle; __d.__incr((value_type*)0), (void) ++__i, ++__p)
+ for (_BidirectionalIterator __i = __first; __i != __middle; __d.__incr((value_type*)0), (void) ++__i, (void) ++__p)
::new(__p) value_type(_VSTD::move(*__i));
__half_inplace_merge(__buff, __p, __middle, __last, __first, __comp);
}
else
{
value_type* __p = __buff;
- for (_BidirectionalIterator __i = __middle; __i != __last; __d.__incr((value_type*)0), (void) ++__i, ++__p)
+ for (_BidirectionalIterator __i = __middle; __i != __last; __d.__incr((value_type*)0), (void) ++__i, (void) ++__p)
::new(__p) value_type(_VSTD::move(*__i));
typedef reverse_iterator<_BidirectionalIterator> _RBi;
typedef reverse_iterator<value_type*> _Rv;
@@ -4575,14 +4575,14 @@ __merge_move_construct(_InputIterator1 _
{
if (__first1 == __last1)
{
- for (; __first2 != __last2; ++__first2, ++__result, __d.__incr((value_type*)0))
+ for (; __first2 != __last2; ++__first2, ++__result, (void) __d.__incr((value_type*)0))
::new (__result) value_type(_VSTD::move(*__first2));
__h.release();
return;
}
if (__first2 == __last2)
{
- for (; __first1 != __last1; ++__first1, ++__result, __d.__incr((value_type*)0))
+ for (; __first1 != __last1; ++__first1, ++__result, (void) __d.__incr((value_type*)0))
::new (__result) value_type(_VSTD::move(*__first1));
__h.release();
return;
@@ -4612,7 +4612,7 @@ __merge_move_assign(_InputIterator1 __fi
{
if (__first2 == __last2)
{
- for (; __first1 != __last1; ++__first1, ++__result)
+ for (; __first1 != __last1; ++__first1, (void) ++__result)
*__result = _VSTD::move(*__first1);
return;
}
@@ -4627,7 +4627,7 @@ __merge_move_assign(_InputIterator1 __fi
++__first1;
}
}
- for (; __first2 != __last2; ++__first2, ++__result)
+ for (; __first2 != __last2; ++__first2, (void) ++__result)
*__result = _VSTD::move(*__first2);
}
@@ -4995,7 +4995,7 @@ void
__sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
{
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
- for (difference_type __n = __last - __first; __n > 1; --__last, --__n)
+ for (difference_type __n = __last - __first; __n > 1; --__last, (void) --__n)
__pop_heap<_Compare>(__first, __last, __comp, __n);
}
@@ -5065,7 +5065,7 @@ __partial_sort_copy(_InputIterator __fir
_RandomAccessIterator __r = __result_first;
if (__r != __result_last)
{
- for (; __first != __last && __r != __result_last; (void) ++__first, ++__r)
+ for (; __first != __last && __r != __result_last; ++__first, (void) ++__r)
*__r = *__first;
__make_heap<_Compare>(__result_first, __r, __comp);
typename iterator_traits<_RandomAccessIterator>::difference_type __len = __r - __result_first;
Modified: libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap.pass.cpp?rev=369448&r1=369447&r2=369448&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap.pass.cpp Tue Aug 20 14:31:51 2019
@@ -17,6 +17,7 @@
#include <cassert>
#include "test_macros.h"
+#include "test_iterators.h"
#if TEST_STD_VER > 17
TEST_CONSTEXPR bool test_constexpr() {
@@ -29,9 +30,13 @@ TEST_CONSTEXPR bool test_constexpr() {
void test()
{
+ typedef random_access_iterator<int *> RI;
int i1[] = {0, 0};
assert(std::is_heap(i1, i1));
assert(std::is_heap(i1, i1+1) == (std::is_heap_until(i1, i1+1) == i1+1));
+ assert(std::is_heap(RI(i1), RI(i1)));
+ assert(std::is_heap(RI(i1), RI(i1+1)) == (std::is_heap_until(RI(i1), RI(i1+1)) == RI(i1+1)));
+
int i2[] = {0, 1};
int i3[] = {1, 0};
assert(std::is_heap(i1, i1+2) == (std::is_heap_until(i1, i1+2) == i1+2));
Modified: libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_comp.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_comp.pass.cpp?rev=369448&r1=369447&r2=369448&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_comp.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_comp.pass.cpp Tue Aug 20 14:31:51 2019
@@ -18,6 +18,7 @@
#include <cassert>
#include "test_macros.h"
+#include "test_iterators.h"
#if TEST_STD_VER > 17
TEST_CONSTEXPR bool test_constexpr() {
@@ -30,9 +31,13 @@ TEST_CONSTEXPR bool test_constexpr() {
void test()
{
+ typedef random_access_iterator<int *> RI;
int i1[] = {0, 0};
assert(std::is_heap(i1, i1, std::greater<int>()));
assert(std::is_heap(i1, i1+1, std::greater<int>()) == (std::is_heap_until(i1, i1+1, std::greater<int>()) == i1+1));
+ assert(std::is_heap(RI(i1), RI(i1), std::greater<int>()));
+ assert(std::is_heap(RI(i1), RI(i1+1), std::greater<int>()) == (std::is_heap_until(RI(i1), RI(i1+1), std::greater<int>()) == RI(i1+1)));
+
int i2[] = {0, 1};
int i3[] = {1, 0};
assert(std::is_heap(i1, i1+2, std::greater<int>()) == (std::is_heap_until(i1, i1+2, std::greater<int>()) == i1+2));
Modified: libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until.pass.cpp?rev=369448&r1=369447&r2=369448&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until.pass.cpp Tue Aug 20 14:31:51 2019
@@ -17,6 +17,7 @@
#include <cassert>
#include "test_macros.h"
+#include "test_iterators.h"
#if TEST_STD_VER > 17
TEST_CONSTEXPR bool test_constexpr() {
@@ -29,9 +30,13 @@ TEST_CONSTEXPR bool test_constexpr() {
void test()
{
+ typedef random_access_iterator<int *> RI;
int i1[] = {0, 0};
assert(std::is_heap_until(i1, i1) == i1);
assert(std::is_heap_until(i1, i1+1) == i1+1);
+ assert(std::is_heap_until(RI(i1), RI(i1)) == RI(i1));
+ assert(std::is_heap_until(RI(i1), RI(i1+1)) == RI(i1+1));
+
int i2[] = {0, 1};
int i3[] = {1, 0};
assert(std::is_heap_until(i1, i1+2) == i1+2);
Modified: libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until_comp.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until_comp.pass.cpp?rev=369448&r1=369447&r2=369448&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until_comp.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until_comp.pass.cpp Tue Aug 20 14:31:51 2019
@@ -18,6 +18,7 @@
#include <cassert>
#include "test_macros.h"
+#include "test_iterators.h"
#if TEST_STD_VER > 17
TEST_CONSTEXPR bool test_constexpr() {
@@ -30,9 +31,13 @@ TEST_CONSTEXPR bool test_constexpr() {
void test()
{
+ typedef random_access_iterator<int *> RI;
int i1[] = {0, 0};
assert(std::is_heap_until(i1, i1, std::greater<int>()) == i1);
assert(std::is_heap_until(i1, i1+1, std::greater<int>()) == i1+1);
+ assert(std::is_heap_until(RI(i1), RI(i1), std::greater<int>()) == RI(i1));
+ assert(std::is_heap_until(RI(i1), RI(i1+1), std::greater<int>()) == RI(i1+1));
+
int i2[] = {0, 1};
int i3[] = {1, 0};
assert(std::is_heap_until(i1, i1+2, std::greater<int>()) == i1+2);
Modified: libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp?rev=369448&r1=369447&r2=369448&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp Tue Aug 20 14:31:51 2019
@@ -18,6 +18,7 @@
#include <cassert>
#include "test_macros.h"
+#include "test_iterators.h"
std::mt19937 randomness;
@@ -29,6 +30,12 @@ void test(int N)
std::shuffle(ia, ia+N, randomness);
std::make_heap(ia, ia+N);
assert(std::is_heap(ia, ia+N));
+
+ typedef random_access_iterator<int *> RI;
+ std::shuffle(RI(ia), RI(ia+N), randomness);
+ std::make_heap(RI(ia), RI(ia+N));
+ assert(std::is_heap(RI(ia), RI(ia+N)));
+
delete [] ia;
}
Modified: libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp?rev=369448&r1=369447&r2=369448&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp Tue Aug 20 14:31:51 2019
@@ -21,6 +21,7 @@
#include "test_macros.h"
#include "counting_predicates.hpp"
+#include "test_iterators.h"
struct indirect_less
{
@@ -40,6 +41,11 @@ void test(int N)
std::shuffle(ia, ia+N, randomness);
std::make_heap(ia, ia+N, std::greater<int>());
assert(std::is_heap(ia, ia+N, std::greater<int>()));
+
+ std::shuffle(ia, ia+N, randomness);
+ std::make_heap(random_access_iterator<int *>(ia),
+ random_access_iterator<int *>(ia+N), std::greater<int>());
+ assert(std::is_heap(ia, ia+N, std::greater<int>()));
}
// Ascending
Modified: libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp?rev=369448&r1=369447&r2=369448&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp Tue Aug 20 14:31:51 2019
@@ -18,6 +18,7 @@
#include <cassert>
#include "test_macros.h"
+#include "test_iterators.h"
std::mt19937 randomness;
@@ -34,6 +35,18 @@ void test(int N)
assert(std::is_heap(ia, ia+i-1));
}
std::pop_heap(ia, ia);
+
+
+ typedef random_access_iterator<int *> RI;
+ std::shuffle(RI(ia), RI(ia+N), randomness);
+ std::make_heap(RI(ia), RI(ia+N));
+ for (int i = N; i > 0; --i)
+ {
+ std::pop_heap(RI(ia), RI(ia+i));
+ assert(std::is_heap(RI(ia), RI(ia+i-1)));
+ }
+ std::pop_heap(RI(ia), RI(ia));
+
delete [] ia;
}
Modified: libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp?rev=369448&r1=369447&r2=369448&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp Tue Aug 20 14:31:51 2019
@@ -20,6 +20,7 @@
#include <memory>
#include "test_macros.h"
+#include "test_iterators.h"
struct indirect_less
{
@@ -44,6 +45,17 @@ void test(int N)
assert(std::is_heap(ia, ia+i-1, std::greater<int>()));
}
std::pop_heap(ia, ia, std::greater<int>());
+
+ typedef random_access_iterator<int *> RI;
+ std::shuffle(RI(ia), RI(ia+N), randomness);
+ std::make_heap(RI(ia), RI(ia+N), std::greater<int>());
+ for (int i = N; i > 0; --i)
+ {
+ std::pop_heap(RI(ia), RI(ia+i), std::greater<int>());
+ assert(std::is_heap(RI(ia), RI(ia+i-1), std::greater<int>()));
+ }
+ std::pop_heap(RI(ia), RI(ia), std::greater<int>());
+
delete [] ia;
}
Modified: libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp?rev=369448&r1=369447&r2=369448&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp Tue Aug 20 14:31:51 2019
@@ -19,6 +19,7 @@
#include <cassert>
#include "test_macros.h"
+#include "test_iterators.h"
std::mt19937 randomness;
@@ -33,6 +34,15 @@ void test(int N)
std::push_heap(ia, ia+i);
assert(std::is_heap(ia, ia+i));
}
+
+ typedef random_access_iterator<int *> RI;
+ std::shuffle(RI(ia), RI(ia+N), randomness);
+ for (int i = 0; i <= N; ++i)
+ {
+ std::push_heap(RI(ia), RI(ia+i));
+ assert(std::is_heap(RI(ia), RI(ia+i)));
+ }
+
delete [] ia;
}
Modified: libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp?rev=369448&r1=369447&r2=369448&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp Tue Aug 20 14:31:51 2019
@@ -21,6 +21,7 @@
#include <memory>
#include "test_macros.h"
+#include "test_iterators.h"
struct indirect_less
{
@@ -42,6 +43,15 @@ void test(int N)
std::push_heap(ia, ia+i, std::greater<int>());
assert(std::is_heap(ia, ia+i, std::greater<int>()));
}
+
+ typedef random_access_iterator<int *> RI;
+ std::shuffle(RI(ia), RI(ia+N), randomness);
+ for (int i = 0; i <= N; ++i)
+ {
+ std::push_heap(RI(ia), RI(ia+i), std::greater<int>());
+ assert(std::is_heap(RI(ia), RI(ia+i), std::greater<int>()));
+ }
+
delete [] ia;
}
Modified: libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp?rev=369448&r1=369447&r2=369448&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp Tue Aug 20 14:31:51 2019
@@ -18,6 +18,7 @@
#include <cassert>
#include "test_macros.h"
+#include "test_iterators.h"
std::mt19937 randomness;
@@ -30,6 +31,13 @@ void test(int N)
std::make_heap(ia, ia+N);
std::sort_heap(ia, ia+N);
assert(std::is_sorted(ia, ia+N));
+
+ typedef random_access_iterator<int *> RI;
+ std::shuffle(RI(ia), RI(ia+N), randomness);
+ std::make_heap(RI(ia), RI(ia+N));
+ std::sort_heap(RI(ia), RI(ia+N));
+ assert(std::is_sorted(RI(ia), RI(ia+N)));
+
delete [] ia;
}
Modified: libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp?rev=369448&r1=369447&r2=369448&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp Tue Aug 20 14:31:51 2019
@@ -20,6 +20,7 @@
#include <memory>
#include "test_macros.h"
+#include "test_iterators.h"
struct indirect_less
{
@@ -39,6 +40,12 @@ void test(int N)
std::make_heap(ia, ia+N, std::greater<int>());
std::sort_heap(ia, ia+N, std::greater<int>());
assert(std::is_sorted(ia, ia+N, std::greater<int>()));
+
+ typedef random_access_iterator<int *> RI;
+ std::shuffle(RI(ia), RI(ia+N), randomness);
+ std::make_heap(RI(ia), RI(ia+N), std::greater<int>());
+ std::sort_heap(RI(ia), RI(ia+N), std::greater<int>());
+ assert(std::is_sorted(RI(ia), RI(ia+N), std::greater<int>()));
delete [] ia;
}
More information about the libcxx-commits
mailing list