[Bug libstdc++/112349] ranges::max makes unnecessary copies
hewillk at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sat Nov 4 12:05:08 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112349
康桓瑋 <hewillk at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hewillk at gmail dot com
--- Comment #2 from 康桓瑋 <hewillk at gmail dot com> ---
(In reply to Jonathan Wakely from comment #1)
>
> I think that would be OK too.
>
> auto __result = *__first;
> while (++__first != __last)
> {
> if (std::__invoke(__comp,
> std::__invoke(__proj, __result),
> std::__invoke(__proj, *__first)))
> __result = *__first;
> }
> return __result;
`auto __result = *__first;` may not be OK, `range_value_t<_Range>
__result(*__first);` is OK.
More information about the Gcc-bugs
mailing list