[libc++] Test that our algorithms never copy a user-provided comparator.
authorArthur O'Dwyer <arthur.j.odwyer@gmail.com>
Thu, 18 Nov 2021 05:07:23 +0000 (00:07 -0500)
committerArthur O'Dwyer <arthur.j.odwyer@gmail.com>
Fri, 19 Nov 2021 20:03:24 +0000 (15:03 -0500)
commitb07b5bd72716625e0976a84d23652d94d8d0165a
tree0e82c9837bfb6063a08b1feb38654129dc5e4957
parentd8e5a0c42bd8796cce9caa53aacab88c7cb2a3eb
[libc++] Test that our algorithms never copy a user-provided comparator.

This is not mandated by the standard, so it goes in libcxx/test/libcxx/.
It's certainly arguable that the algorithms changed here
(`is_heap`, `is_sorted`, `min`, `max`) are harmless and we should
just let them copy their comparators once. But at the same time,
it's nice to have all our algorithms be 100% consistent and never
copy a comparator, not even once.

Differential Revision: https://reviews.llvm.org/D114136
12 files changed:
libcxx/include/__algorithm/binary_search.h
libcxx/include/__algorithm/is_heap.h
libcxx/include/__algorithm/is_heap_until.h
libcxx/include/__algorithm/is_sorted.h
libcxx/include/__algorithm/is_sorted_until.h
libcxx/include/__algorithm/max.h
libcxx/include/__algorithm/max_element.h
libcxx/include/__algorithm/min.h
libcxx/include/__algorithm/min_element.h
libcxx/test/libcxx/algorithms/robust_against_copying_comparators.pass.cpp [new file with mode: 0644]
libcxx/test/std/algorithms/robust_against_adl.compile.pass.cpp
libcxx/test/std/algorithms/robust_re_difference_type.compile.pass.cpp