libstdc++: Move-only input iterator support in <memory> algorithms (LWG 3355)
authorPatrick Palka <ppalka@redhat.com>
Tue, 3 Mar 2020 00:39:46 +0000 (19:39 -0500)
committerPatrick Palka <ppalka@redhat.com>
Wed, 4 Mar 2020 03:44:39 +0000 (22:44 -0500)
commit144dfc68d0c0f5b99a0cd0a14b211f82afed88c6
treefce1c69a345fe914fd8b7962e6277a183d155ebb
parent26af9cd8af1b3b603434586a17127d8c3d2d8266
libstdc++: Move-only input iterator support in <memory> algorithms (LWG 3355)

This adds support for move-only input iterators in the ranges::unitialized_*
algorithms defined in <memory>, as per LWG 3355.  The only changes needed are to
add calls to std::move in the appropriate places and to use operator- instead of
ranges::distance because the latter cannot be used with a move-only iterator
that has a sized sentinel, as is the case here.  (This issue with
ranges::distance is LWG 3392.)

libstdc++-v3/ChangeLog:

LWG 3355 The memory algorithms should support move-only input iterators
introduced by P1207
* include/bits/ranges_uninitialized.h
(__uninitialized_copy_fn::operator()): Use std::move to avoid attempting
to copy __ifirst, which could be a move-only input iterator.  Use
operator- instead of ranges::distance to compute distance from a sized
sentinel.
(__uninitialized_copy_n_fn::operator()): Likewise.
(__uninitialized_move_fn::operator()): Likewise.
(__uninitialized_move_n_fn::operator()): Likewise.
(__uninitialized_destroy_fn::operator()): Use std::move to avoid
attempting to copy __first.
(__uninitialized_destroy_n_fn::operator()): Likewise.
* testsuite/20_util/specialized_algorithms/destroy/constrained.cc:
Augment test.
* .../specialized_algorithms/uninitialized_copy/constrained.cc:
Likewise.
* .../specialized_algorithms/uninitialized_move/constrained.cc:
Likewise.
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/ranges_uninitialized.h
libstdc++-v3/testsuite/20_util/specialized_algorithms/destroy/constrained.cc
libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc
libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc