Skip to content
Snippets Groups Projects
Commit b8314ebf authored by Patrick Palka's avatar Patrick Palka
Browse files

libstdc++: Avoid unnecessary copies in ranges::min/max [PR112349]


Use a local reference for the (now possibly lifetime extended) result of
*__first so that we copy it only when necessary.

	PR libstdc++/112349

libstdc++-v3/ChangeLog:

	* include/bits/ranges_algo.h (__min_fn::operator()): Turn local
	object __tmp into a reference.
	* include/bits/ranges_util.h (__max_fn::operator()): Likewise.
	* testsuite/25_algorithms/max/constrained.cc (test04): New test.
	* testsuite/25_algorithms/min/constrained.cc (test04): New test.

Reviewed-by: default avatarJonathan Wakely <jwakely@redhat.com>
parent 20890092
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment