]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Fix std::ranges::iter_move for function references [PR119469]
authorJonathan Wakely <jwakely@redhat.com>
Wed, 26 Mar 2025 11:21:32 +0000 (11:21 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 2 Apr 2025 08:55:46 +0000 (09:55 +0100)
commit88f0c1fe2825056f6d5fefa7809d878b109e7019
tree04622712d109afa4f7f7306521d6fbdeac32d48b
parent58a2b7f05587485f846490e21e4de3d51d83afb9
libstdc++: Fix std::ranges::iter_move for function references [PR119469]

The result of std::move (or a cast to an rvalue reference) on a function
reference is always an lvalue. Because std::ranges::iter_move was using
the type std::remove_reference_t<X>&& as the result of std::move, it was
giving the wrong type for function references. Use a decltype-specifier
with declval<remove_reference_t<X>>() instead of just using the
remove_reference_t<X>&& type directly. This gives the right result,
while still avoiding the cost of doing overload resolution for
std::move.

libstdc++-v3/ChangeLog:

PR libstdc++/119469
* include/bits/iterator_concepts.h (_IterMove::__result): Use
decltype-specifier instead of an explicit type.
* testsuite/24_iterators/customization_points/iter_move.cc:
Check results for function references.

Reviewed-by: Tomasz KamiƄski <tkaminsk@redhat.com>
(cherry picked from commit 3e52eb28c537aaa03afb78ef9dff8325c5f41f78)
libstdc++-v3/include/bits/iterator_concepts.h
libstdc++-v3/testsuite/24_iterators/customization_points/iter_move.cc