Tomasz Kamiński ea8ef43971 libstdc++: Add nodiscard attribute for ranges algorithm [PR121476]
This patch adds the [[nodiscard]] attribute to the operator() of ranges
algorithm function objects if their std counterpart has it.

Furthermore, we [[nodiscard]] the operator() of the following ranges
algorithms that lack a std counterpart:
* find_last, find_last_if, find_last_if_not (to match other find
  algorithms)
* contains, contains_subrange (to match find/any_of and search)

Finally, [[nodiscard]] is added to std::min and std::max overloads
that accept std::initializer_list. This appears to be an oversight,
as std::minmax is already marked, and other min overloads are as well.
The same applies to corresponding operator() overloads of ranges::min and
ranges::max.

	PR libstdc++/121476

libstdc++-v3/ChangeLog:

	* include/bits/ranges_algo.h (__all_of_fn::operator()):
	(__any_of_fn::operator(), __none_of_fn::operator())
	(__find_first_of_fn::operator(), __count_fn::operator())
	(__find_end_fn::operator(), __remove_if_fn::operator())
	(__remove_fn::operator(), __unique_fn::operator())
	(__is_sorted_until_fn::operator(), __is_sorted_fn::operator())
	(__lower_bound_fn::operator(), __upper_bound_fn::operator())
	(__equal_range_fn::operator(), __binary_search_fn::operator())
	(__is_partitioned_fn::operator(), __partition_point_fn::operator())
	(__minmax_fn::operator(), __min_element_fn::operator())
	(__includes_fn::operator(), __max_fn::operator())
	(__lexicographical_compare_fn::operator(), __clamp__fn::operator())
	(__find_last_fn::operator(), __find_last_if_fn::operator())
	(__find_last_if_not_fn::operator()): Add [[nodiscard]] attribute.
	* include/bits/ranges_algobase.h (__equal_fn::operator()):
	Add [[nodiscard]] attribute.
	* include/bits/ranges_util.h (__find_fn::operator())
	(__find_if_fn::operator(), __find_if_not_fn::operator())
	(__mismatch_fn::operator(), __search_fn::operator())
	(__min_fn::operator(), __adjacent_find_fn::operator()):
	Add [[nodiscard]] attribute.
	* include/bits/stl_algo.h (std::min(initializer_list<T>))
	(std::min(initializer_list<T>, _Compare))
	(std::max(initializer_list<T>))
	(std::mmax(initializer_list<T>, _Compare)): Add _GLIBCXX_NODISCARD.
	* testsuite/25_algorithms/min/constrained.cc: Silence nodiscard
	warning.
	* testsuite/25_algorithms/max/constrained.cc: Likewise.
	* testsuite/25_algorithms/minmax/constrained.cc: Likewise.
	* testsuite/25_algorithms/minmax_element/constrained.cc: Likewise.
2025-08-18 14:05:06 +02:00
2025-06-03 00:18:06 +00:00
2025-08-11 00:16:52 +00:00
2025-08-18 00:18:52 +00:00
2025-08-16 00:19:12 +00:00
2025-06-23 00:16:33 +00:00
2025-08-17 00:19:17 +00:00
2025-08-01 00:20:20 +00:00
2025-04-11 00:17:32 +00:00
2025-07-26 00:19:51 +00:00
2025-08-16 00:19:12 +00:00
2025-08-14 00:20:55 +00:00
2025-08-14 00:20:55 +00:00
2025-08-07 00:20:46 +00:00
2025-07-24 00:20:56 +00:00
2025-08-07 00:20:46 +00:00
2025-08-06 00:21:26 +00:00
2025-08-17 00:19:17 +00:00
2025-05-10 00:17:59 +00:00
2025-07-02 00:19:39 +00:00
2025-04-10 00:18:06 +00:00
2025-05-10 00:17:59 +00:00
2025-07-05 00:19:48 +00:00
2025-08-01 00:20:20 +00:00
2025-08-18 00:18:52 +00:00

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.
Description
No description provided
Readme 2.7 GiB
Languages
C++ 30.7%
C 30.1%
Ada 14.4%
D 6.1%
Go 5.7%
Other 12.5%