diff --git a/libcxx/include/__memory/ranges_uninitialized_algorithms.h b/libcxx/include/__memory/ranges_uninitialized_algorithms.h --- a/libcxx/include/__memory/ranges_uninitialized_algorithms.h +++ b/libcxx/include/__memory/ranges_uninitialized_algorithms.h @@ -256,7 +256,7 @@ sentinel_for<_InputIterator> _Sentinel1, __nothrow_forward_iterator _OutputIterator, __nothrow_sentinel_for<_OutputIterator> _Sentinel2> - requires constructible_from, iter_reference_t<_InputIterator>> + requires constructible_from, iter_rvalue_reference_t<_InputIterator>> uninitialized_move_result<_InputIterator, _OutputIterator> operator()(_InputIterator __ifirst, _Sentinel1 __ilast, _OutputIterator __ofirst, _Sentinel2 __olast) const { using _ValueType = remove_reference_t>; @@ -267,7 +267,7 @@ } template - requires constructible_from, range_reference_t<_InputRange>> + requires constructible_from, range_rvalue_reference_t<_InputRange>> uninitialized_move_result, borrowed_iterator_t<_OutputRange>> operator()(_InputRange&& __in_range, _OutputRange&& __out_range) const { return (*this)(ranges::begin(__in_range), ranges::end(__in_range), @@ -292,7 +292,7 @@ template _Sentinel> - requires constructible_from, iter_reference_t<_InputIterator>> + requires constructible_from, iter_rvalue_reference_t<_InputIterator>> uninitialized_move_n_result<_InputIterator, _OutputIterator> operator()(_InputIterator __ifirst, iter_difference_t<_InputIterator> __n, _OutputIterator __ofirst, _Sentinel __olast) const { diff --git a/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.move/ranges_uninitialized_move.pass.cpp b/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.move/ranges_uninitialized_move.pass.cpp --- a/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.move/ranges_uninitialized_move.pass.cpp +++ b/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.move/ranges_uninitialized_move.pass.cpp @@ -17,6 +17,7 @@ #include +#include #include #include #include @@ -26,6 +27,7 @@ #include "../buffer.h" #include "../counted.h" +#include "MoveOnly.h" #include "test_macros.h" #include "test_iterators.h" @@ -417,5 +419,21 @@ } } + // MoveOnly types are supported + { + { + MoveOnly a[] = {1, 2, 3, 4}; + Buffer out; + std::ranges::uninitialized_move(std::begin(a), std::end(a), std::begin(out), std::end(out)); + assert(std::ranges::equal(out, std::array{1, 2, 3, 4})); + } + { + MoveOnly a[] = {1, 2, 3, 4}; + Buffer out; + std::ranges::uninitialized_move(a, out); + assert(std::ranges::equal(out, std::array{1, 2, 3, 4})); + } + } + return 0; } diff --git a/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.move/ranges_uninitialized_move_n.pass.cpp b/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.move/ranges_uninitialized_move_n.pass.cpp --- a/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.move/ranges_uninitialized_move_n.pass.cpp +++ b/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.move/ranges_uninitialized_move_n.pass.cpp @@ -15,6 +15,7 @@ // uninitialized_copy_n_result uninitialized_copy_n(I ifirst, iter_difference_t n, O ofirst, S olast); // since C++20 #include +#include #include #include #include @@ -23,6 +24,7 @@ #include "../buffer.h" #include "../counted.h" +#include "MoveOnly.h" #include "test_iterators.h" #include "test_macros.h" @@ -179,5 +181,15 @@ std::ranges::uninitialized_move_n(std::move(in), N, out.begin(), out.end()); } + // MoveOnly types are supported + { + { + MoveOnly a[] = {1, 2, 3, 4}; + Buffer out; + std::ranges::uninitialized_move_n(std::begin(a), std::size(a), std::begin(out), std::end(out)); + assert(std::ranges::equal(out, std::array{1, 2, 3, 4})); + } + } + return 0; }