[gcc(refs/users/ppalka/heads/libstdcxx-constrained-algos)] Fix a few more wrong copyability assumptions not yet caught by the unit tests
Patrick Palka
ppalka@gcc.gnu.org
Wed Jan 22 18:52:00 GMT 2020
https://gcc.gnu.org/g:9dd755044261938dd4ce9584009c8c7485f2ebd0
commit 9dd755044261938dd4ce9584009c8c7485f2ebd0
Author: Patrick Palka <ppalka@redhat.com>
Date: Wed Jan 22 13:51:18 2020 -0500
Fix a few more wrong copyability assumptions not yet caught by the unit tests
Diff:
---
libstdc++-v3/include/bits/ranges_algo.h | 4 ++--
.../testsuite/25_algorithms/transform/constrained.cc | 13 +++++++------
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/libstdc++-v3/include/bits/ranges_algo.h b/libstdc++-v3/include/bits/ranges_algo.h
index 7cc83b1..6788085 100644
--- a/libstdc++-v3/include/bits/ranges_algo.h
+++ b/libstdc++-v3/include/bits/ranges_algo.h
@@ -982,7 +982,7 @@ namespace ranges
{
for (; __first1 != __last1; ++__first1, (void)++__result)
*__result = std::__invoke(__op, std::__invoke(__proj, *__first1));
- return {std::move(__first1), __result};
+ return {std::move(__first1), std::move(__result)};
}
template<input_range _Range, weakly_incrementable _Out,
@@ -1037,7 +1037,7 @@ namespace ranges
*__result = std::__invoke(__binary_op,
std::__invoke(__proj1, *__first1),
std::__invoke(__proj2, *__first2));
- return {std::move(__first1), std::move(__first2), __result};
+ return {std::move(__first1), std::move(__first2), std::move(__result)};
}
template<input_range _Range1, input_range _Range2,
diff --git a/libstdc++-v3/testsuite/25_algorithms/transform/constrained.cc b/libstdc++-v3/testsuite/25_algorithms/transform/constrained.cc
index 2af2f38..da8b7f2 100644
--- a/libstdc++-v3/testsuite/25_algorithms/transform/constrained.cc
+++ b/libstdc++-v3/testsuite/25_algorithms/transform/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;
@@ -59,11 +60,11 @@ test01()
X y[7] = { {3}, {5}, {7}, {9}, {11}, {12}, {0} };
int z[7] = { {0}, {0}, {0}, {0}, {0}, {0}, {0} };
test_range<X, input_iterator_wrapper> rx(x), ry(y);
- test_range<int, forward_iterator_wrapper> rz(z);
+ test_range<int, output_iterator_wrapper> rz(z);
auto [in, out]
= ranges::transform(rx, rz.begin(), [] (int a) { return a+1; }, &X::i);
- VERIFY( ranges::equal(ry, rz, {}, &X::i) );
- VERIFY( in == rx.end() && ++out == rz.end() );
+ VERIFY( ranges::equal(ry, z, {}, &X::i) );
+ VERIFY( in == rx.end() && out.ptr == z+6 );
}
}
@@ -119,11 +120,11 @@ test03()
int w[6];
test_range<X, input_iterator_wrapper> rx(x);
test_range<int, input_iterator_wrapper> ry(y), rz(z);
- test_range<int, forward_iterator_wrapper> rw(w);
+ test_range<int, output_iterator_wrapper> rw(w);
auto [in1, in2, out]
= ranges::transform(rx, ry, rw.begin(), std::plus<>{}, &X::i);
- VERIFY( in1 == rx.end() && ++in2 == ry.end() && out == rw.end() );
- VERIFY( ranges::equal(rw, rz) );
+ VERIFY( in1 == rx.end() && ++in2 == ry.end() && out.ptr == w+6 );
+ VERIFY( ranges::equal(w, rz) );
}
}
More information about the Libstdc++-cvs
mailing list