]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Fix ranges::move and ranges::move_backward to use iter_move [PR105609]
authorJonathan Wakely <jwakely@redhat.com>
Thu, 27 Feb 2025 13:27:17 +0000 (13:27 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Fri, 28 Feb 2025 21:35:27 +0000 (21:35 +0000)
commit3866ca796d5281d33f25b4165badacf8f198c6d1
treef258fc80ee51dece3bc84c559d300d42c63ce9c8
parenta9cfcd0d9e3780c71442057f636f62a7142056cb
libstdc++: Fix ranges::move and ranges::move_backward to use iter_move [PR105609]

The ranges::move and ranges::move_backward algorithms are supposed to
use ranges::iter_move(iter) instead of std::move(*iter), which matters
for an iterator type with an iter_move overload findable by ADL.

Currently those algorithms use std::__assign_one which uses std::move,
so define a new ranges::__detail::__assign_one helper function that uses
ranges::iter_move.

libstdc++-v3/ChangeLog:

PR libstdc++/105609
* include/bits/ranges_algobase.h (__detail::__assign_one): New
helper function.
(__copy_or_move, __copy_or_move_backward): Use new function
instead of std::__assign_one.
* testsuite/25_algorithms/move/constrained.cc: Check that
ADL iter_move is used in preference to std::move.
* testsuite/25_algorithms/move_backward/constrained.cc:
Likewise.
libstdc++-v3/include/bits/ranges_algobase.h
libstdc++-v3/testsuite/25_algorithms/move/constrained.cc
libstdc++-v3/testsuite/25_algorithms/move_backward/constrained.cc