gcc/libstdc++-v3/testsuite/25_algorithms
Jonathan Wakely df483ebd24 libstdc++: Add nodiscard in <algorithm>
Add the [[nodiscard]] attribute to several functions in <algorithm>.
These all have no side effects and are only called for their return
value (e.g. std::count) or produce a result that must not be discarded
for correctness (e.g. std::remove).

I was intending to add the attribute to a number of other functions like
std::copy_if, std::unique_copy, std::set_union, and std::set_difference.
I stopped when I noticed that MSVC doesn't use it on those functions,
which I suspect is because they're often used with an insert iterator
(e.g. std::back_insert_iterator). In that case it doesn't matter if
you discard the result, because you have the container to tell you how
many elements were copied to the output range.

libstdc++-v3/ChangeLog:

	* include/bits/stl_algo.h (find_end, all_of, none_of, any_of)
	(find_if_not, is_partitioned, partition_point, remove)
	(remove_if, unique, lower_bound, upper_bound, equal_range)
	(binary_search, includes, is_sorted, is_sorted_until, minmax)
	(minmax_element, is_permutation, clamp, find_if, find_first_of)
	(adjacent_find, count, count_if, search, search_n, min_element)
	(max_element): Add nodiscard attribute.
	* include/bits/stl_algobase.h (min, max, lower_bound, equal)
	(lexicographical_compare, lexicographical_compare_three_way)
	(mismatch): Likewise.
	* include/bits/stl_heap.h (is_heap, is_heap_until): Likewise.
	* testsuite/25_algorithms/equal/debug/1_neg.cc: Add dg-warning.
	* testsuite/25_algorithms/equal/debug/2_neg.cc: Likewise.
	* testsuite/25_algorithms/equal/debug/3_neg.cc: Likewise.
	* testsuite/25_algorithms/find_first_of/concept_check_1.cc:
	Likewise.
	* testsuite/25_algorithms/is_permutation/2.cc: Likewise.
	* testsuite/25_algorithms/lexicographical_compare/71545.cc:
	Likewise.
	* testsuite/25_algorithms/lower_bound/33613.cc: Likewise.
	* testsuite/25_algorithms/lower_bound/debug/irreflexive.cc:
	Likewise.
	* testsuite/25_algorithms/lower_bound/debug/partitioned_neg.cc:
	Likewise.
	* testsuite/25_algorithms/lower_bound/debug/partitioned_pred_neg.cc:
	Likewise.
	* testsuite/25_algorithms/minmax/3.cc: Likewise.
	* testsuite/25_algorithms/search/78346.cc: Likewise.
	* testsuite/25_algorithms/search_n/58358.cc: Likewise.
	* testsuite/25_algorithms/unique/1.cc: Likewise.
	* testsuite/25_algorithms/unique/11480.cc: Likewise.
	* testsuite/25_algorithms/upper_bound/33613.cc: Likewise.
	* testsuite/25_algorithms/upper_bound/debug/partitioned_neg.cc:
	Likewise.
	* testsuite/25_algorithms/upper_bound/debug/partitioned_pred_neg.cc:
	Likewise.
	* testsuite/ext/concept_checks.cc: Likewise.
	* testsuite/ext/is_heap/47709.cc: Likewise.
	* testsuite/ext/is_sorted/cxx0x.cc: Likewise.
2024-03-14 16:58:15 +00:00
..
adjacent_find Update copyright years. 2024-01-03 12:19:35 +01:00
advance/istreambuf_iterators Update copyright years. 2024-01-03 12:19:35 +01:00
all_of Update copyright years. 2024-01-03 12:19:35 +01:00
any_of Update copyright years. 2024-01-03 12:19:35 +01:00
binary_search Update copyright years. 2024-01-03 12:19:35 +01:00
clamp Update copyright years. 2024-01-03 12:19:35 +01:00
contains libstdc++: Remove dg-options "-std=gnu++23" from remaining tests 2023-09-15 21:57:40 +01:00
contains_subrange libstdc++: Remove dg-options "-std=gnu++23" from remaining tests 2023-09-15 21:57:40 +01:00
copy libstdc++: Update expected error for debug/constexpr*_neg.cc tests 2024-02-01 15:26:53 +00:00
copy_backward libstdc++: Update expected error for debug/constexpr*_neg.cc tests 2024-02-01 15:26:53 +00:00
copy_if Update copyright years. 2024-01-03 12:19:35 +01:00
copy_n Update copyright years. 2024-01-03 12:19:35 +01:00
count Update copyright years. 2024-01-03 12:19:35 +01:00
count_if Update copyright years. 2024-01-03 12:19:35 +01:00
equal libstdc++: Add nodiscard in <algorithm> 2024-03-14 16:58:15 +00:00
equal_range Update copyright years. 2024-01-03 12:19:35 +01:00
fill Update copyright years. 2024-01-03 12:19:35 +01:00
fill_n Update copyright years. 2024-01-03 12:19:35 +01:00
find Update copyright years. 2024-01-03 12:19:35 +01:00
find_end Update copyright years. 2024-01-03 12:19:35 +01:00
find_first_of libstdc++: Add nodiscard in <algorithm> 2024-03-14 16:58:15 +00:00
find_if Update copyright years. 2024-01-03 12:19:35 +01:00
find_if_not Update copyright years. 2024-01-03 12:19:35 +01:00
find_last libstdc++: Remove dg-options "-std=gnu++23" from remaining tests 2023-09-15 21:57:40 +01:00
find_last_if libstdc++: Remove dg-options "-std=gnu++23" from remaining tests 2023-09-15 21:57:40 +01:00
find_last_if_not libstdc++: Remove dg-options "-std=gnu++23" from remaining tests 2023-09-15 21:57:40 +01:00
fold_left libstdc++: Test for feature test macros more accurately 2023-11-16 08:06:59 +00:00
fold_right libstdc++: Remove dg-options "-std=gnu++23" from remaining tests 2023-09-15 21:57:40 +01:00
for_each Update copyright years. 2024-01-03 12:19:35 +01:00
generate Update copyright years. 2024-01-03 12:19:35 +01:00
generate_n Update copyright years. 2024-01-03 12:19:35 +01:00
headers Update copyright years. 2024-01-03 12:19:35 +01:00
heap Update copyright years. 2024-01-03 12:19:35 +01:00
includes Update copyright years. 2024-01-03 12:19:35 +01:00
inplace_merge Update copyright years. 2024-01-03 12:19:35 +01:00
iota libstdc++: Remove dg-options "-std=gnu++23" from remaining tests 2023-09-15 21:57:40 +01:00
is_heap Update copyright years. 2024-01-03 12:19:35 +01:00
is_heap_until Update copyright years. 2024-01-03 12:19:35 +01:00
is_partitioned Update copyright years. 2024-01-03 12:19:35 +01:00
is_permutation libstdc++: Add nodiscard in <algorithm> 2024-03-14 16:58:15 +00:00
is_sorted Update copyright years. 2024-01-03 12:19:35 +01:00
is_sorted_until Update copyright years. 2024-01-03 12:19:35 +01:00
iter_swap Update copyright years. 2024-01-03 12:19:35 +01:00
lexicographical_compare libstdc++: Add nodiscard in <algorithm> 2024-03-14 16:58:15 +00:00
lexicographical_compare_three_way libstdc++: Fix conditions for using memcmp in std::lexicographical_compare_three_way [PR113960] 2024-02-29 17:49:43 +00:00
lower_bound libstdc++: Add nodiscard in <algorithm> 2024-03-14 16:58:15 +00:00
make_heap Update copyright years. 2024-01-03 12:19:35 +01:00
max Update copyright years. 2024-01-03 12:19:35 +01:00
max_element Update copyright years. 2024-01-03 12:19:35 +01:00
merge Update copyright years. 2024-01-03 12:19:35 +01:00
min Update copyright years. 2024-01-03 12:19:35 +01:00
min_element Update copyright years. 2024-01-03 12:19:35 +01:00
minmax libstdc++: Add nodiscard in <algorithm> 2024-03-14 16:58:15 +00:00
minmax_element Update copyright years. 2024-01-03 12:19:35 +01:00
mismatch Update copyright years. 2024-01-03 12:19:35 +01:00
move Update copyright years. 2024-01-03 12:19:35 +01:00
move_backward Update copyright years. 2024-01-03 12:19:35 +01:00
next_permutation Update copyright years. 2024-01-03 12:19:35 +01:00
none_of Update copyright years. 2024-01-03 12:19:35 +01:00
nth_element Update copyright years. 2024-01-03 12:19:35 +01:00
partial_sort Update copyright years. 2024-01-03 12:19:35 +01:00
partial_sort_copy Update copyright years. 2024-01-03 12:19:35 +01:00
partition Update copyright years. 2024-01-03 12:19:35 +01:00
partition_copy Update copyright years. 2024-01-03 12:19:35 +01:00
partition_point Update copyright years. 2024-01-03 12:19:35 +01:00
pop_heap Update copyright years. 2024-01-03 12:19:35 +01:00
prev_permutation Update copyright years. 2024-01-03 12:19:35 +01:00
pstl libstdc++: Fix invalid order in PSTL inplace_merge test [PR90276] 2024-02-02 10:27:16 +00:00
push_heap Update copyright years. 2024-01-03 12:19:35 +01:00
random_shuffle Update copyright years. 2024-01-03 12:19:35 +01:00
remove Update copyright years. 2024-01-03 12:19:35 +01:00
remove_copy Update copyright years. 2024-01-03 12:19:35 +01:00
remove_copy_if Update copyright years. 2024-01-03 12:19:35 +01:00
remove_if Update copyright years. 2024-01-03 12:19:35 +01:00
replace Update copyright years. 2024-01-03 12:19:35 +01:00
replace_copy Update copyright years. 2024-01-03 12:19:35 +01:00
replace_copy_if Update copyright years. 2024-01-03 12:19:35 +01:00
replace_if Update copyright years. 2024-01-03 12:19:35 +01:00
reverse Update copyright years. 2024-01-03 12:19:35 +01:00
reverse_copy Update copyright years. 2024-01-03 12:19:35 +01:00
rotate Update copyright years. 2024-01-03 12:19:35 +01:00
rotate_copy Update copyright years. 2024-01-03 12:19:35 +01:00
sample Update copyright years. 2024-01-03 12:19:35 +01:00
search libstdc++: Add nodiscard in <algorithm> 2024-03-14 16:58:15 +00:00
search_n libstdc++: Add nodiscard in <algorithm> 2024-03-14 16:58:15 +00:00
set_difference Update copyright years. 2024-01-03 12:19:35 +01:00
set_intersection Update copyright years. 2024-01-03 12:19:35 +01:00
set_symmetric_difference Update copyright years. 2024-01-03 12:19:35 +01:00
set_union Update copyright years. 2024-01-03 12:19:35 +01:00
shift_left Update copyright years. 2024-01-03 12:19:35 +01:00
shift_right Update copyright years. 2024-01-03 12:19:35 +01:00
shuffle Update copyright years. 2024-01-03 12:19:35 +01:00
sort Update copyright years. 2024-01-03 12:19:35 +01:00
sort_heap Update copyright years. 2024-01-03 12:19:35 +01:00
stable_partition Update copyright years. 2024-01-03 12:19:35 +01:00
stable_sort Update copyright years. 2024-01-03 12:19:35 +01:00
swap Update copyright years. 2024-01-03 12:19:35 +01:00
swap_ranges Update copyright years. 2024-01-03 12:19:35 +01:00
transform Update copyright years. 2024-01-03 12:19:35 +01:00
unique libstdc++: Add nodiscard in <algorithm> 2024-03-14 16:58:15 +00:00
unique_copy Update copyright years. 2024-01-03 12:19:35 +01:00
upper_bound libstdc++: Add nodiscard in <algorithm> 2024-03-14 16:58:15 +00:00
constexpr_macro.cc Update copyright years. 2024-01-03 12:19:35 +01:00
cpp_lib_constexpr.cc Update copyright years. 2024-01-03 12:19:35 +01:00