[gcc(refs/users/ppalka/heads/libstdcxx-constrained-algos)] Make ranges::replace_copy and ranges::replace_copy_if move-only-safe
Patrick Palka
ppalka@gcc.gnu.org
Wed Jan 22 23:02:00 GMT 2020
https://gcc.gnu.org/g:7ab99d1fa425a6d89021172fe464b2ae616ca779
commit 7ab99d1fa425a6d89021172fe464b2ae616ca779
Author: Patrick Palka <ppalka@redhat.com>
Date: Wed Jan 22 17:57:12 2020 -0500
Make ranges::replace_copy and ranges::replace_copy_if move-only-safe
Diff:
---
libstdc++-v3/include/bits/ranges_algo.h | 4 ++--
libstdc++-v3/testsuite/25_algorithms/replace_copy/constrained.cc | 8 +++++---
.../testsuite/25_algorithms/replace_copy_if/constrained.cc | 8 +++++---
3 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/libstdc++-v3/include/bits/ranges_algo.h b/libstdc++-v3/include/bits/ranges_algo.h
index 466a2d8..07e957d 100644
--- a/libstdc++-v3/include/bits/ranges_algo.h
+++ b/libstdc++-v3/include/bits/ranges_algo.h
@@ -1135,7 +1135,7 @@ namespace ranges
*__result = __new_value;
else
*__result = *__first;
- return {__first, __result};
+ return {std::move(__first), std::move(__result)};
}
template<input_range _Range, typename _Tp1, typename _Tp2,
@@ -1171,7 +1171,7 @@ namespace ranges
*__result = __new_value;
else
*__result = *__first;
- return {__first, __result};
+ return {std::move(__first), std::move(__result)};
}
template<input_range _Range,
diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_copy/constrained.cc b/libstdc++-v3/testsuite/25_algorithms/replace_copy/constrained.cc
index 0d792bc..12e76a4 100644
--- a/libstdc++-v3/testsuite/25_algorithms/replace_copy/constrained.cc
+++ b/libstdc++-v3/testsuite/25_algorithms/replace_copy/constrained.cc
@@ -25,6 +25,7 @@
using __gnu_test::test_container;
using __gnu_test::test_range;
using __gnu_test::input_iterator_wrapper;
+using __gnu_test::output_iterator_wrapper;
using __gnu_test::forward_iterator_wrapper;
namespace ranges = std::ranges;
@@ -74,11 +75,12 @@ test01()
{
X x[6] = { {2}, {2}, {6}, {8}, {10}, {11} };
X y[6];
- X z[6] = { {7}, {7}, {6}, {8}, {10}, {11} };
- test_range<X, forward_iterator_wrapper> cx(x), cy(y), cz(z);
+ const X z[6] = { {7}, {7}, {6}, {8}, {10}, {11} };
+ test_range<X, input_iterator_wrapper> cx(x);
+ test_range<X, output_iterator_wrapper> cy(y);
auto [in, out] = ranges::replace_copy(cx, cy.begin(), 2, X{7}, &X::i);
VERIFY( in == cx.end() && out == cy.end() );
- VERIFY( ranges::equal(cy, cz) );
+ VERIFY( ranges::equal(y, z) );
}
}
diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/constrained.cc b/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/constrained.cc
index 599fdfe..9186a0a 100644
--- a/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/constrained.cc
+++ b/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/constrained.cc
@@ -25,6 +25,7 @@
using __gnu_test::test_container;
using __gnu_test::test_range;
using __gnu_test::input_iterator_wrapper;
+using __gnu_test::output_iterator_wrapper;
using __gnu_test::forward_iterator_wrapper;
namespace ranges = std::ranges;
@@ -80,12 +81,13 @@ test01()
{
X x[6] = { {2}, {2}, {6}, {8}, {10}, {11} };
X y[6];
- X z[6] = { {7}, {7}, {6}, {8}, {10}, {11} };
- test_range<X, forward_iterator_wrapper> cx(x), cy(y), cz(z);
+ const X z[6] = { {7}, {7}, {6}, {8}, {10}, {11} };
+ test_range<X, input_iterator_wrapper> cx(x);
+ test_range<X, output_iterator_wrapper> cy(y);
auto [in, out] = ranges::replace_copy_if(cx, cy.begin(),
is_two_p, X{7}, &X::i);
VERIFY( in == cx.end() && out == cy.end() );
- VERIFY( ranges::equal(cy, cz) );
+ VERIFY( ranges::equal(y, z) );
}
}
More information about the Libstdc++-cvs
mailing list