From 4c65085391c06df2a7b1acb4767e63aee6763d2c Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 31 Jul 2009 22:26:32 -0400 Subject: [PATCH] forward_list.h (splice_after): Use forward. * include/bits/forward_list.h (splice_after): Use forward. (merge): Likewise. * include/bits/stl_iterator.h (move_iterator::operator*): Use move. (move_iterator::operator[]): Use move. * include/bits/stl_list.h (insert): Use move. * include/std/thread (_Callable constructor): Use forward. * include/std/tuple: Don't specify explicit template args to move. From-SVN: r150326 --- libstdc++-v3/ChangeLog | 29 +++++++++++++++++++ libstdc++-v3/include/bits/forward_list.h | 7 +++-- libstdc++-v3/include/bits/stl_iterator.h | 4 +-- libstdc++-v3/include/bits/stl_list.h | 10 ++++++- libstdc++-v3/include/std/thread | 5 +++- libstdc++-v3/include/std/tuple | 13 ++++----- .../requirements/explicit_instantiation.cc | 2 +- .../20_util/shared_ptr/assign/auto_ptr.cc | 2 +- .../20_util/shared_ptr/assign/auto_ptr_neg.cc | 2 +- .../20_util/shared_ptr/cons/auto_ptr.cc | 2 +- .../20_util/shared_ptr/cons/auto_ptr_neg.cc | 2 +- libstdc++-v3/testsuite/20_util/tuple/swap.cc | 2 +- .../forward_list/ext_pointer/operations/1.cc | 6 ++-- .../forward_list/ext_pointer/operations/5.cc | 2 +- .../forward_list/operations/1.cc | 6 ++-- .../forward_list/operations/5.cc | 2 +- .../list/requirements/dr438/assign_neg.cc | 2 +- .../requirements/dr438/constructor_1_neg.cc | 2 +- .../requirements/dr438/constructor_2_neg.cc | 2 +- .../list/requirements/dr438/insert_neg.cc | 2 +- .../30_threads/shared_future/cons/copy.cc | 2 +- .../30_threads/thread/cons/assign_neg.cc | 2 +- 22 files changed, 75 insertions(+), 33 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 9707f48627c..eb8b0e727fe 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,32 @@ +2009-07-31 Jason Merrill + + * include/bits/forward_list.h (splice_after): Use forward. + (merge): Likewise. + * include/bits/stl_iterator.h (move_iterator::operator*): Use move. + (move_iterator::operator[]): Use move. + * include/bits/stl_list.h (insert): Use move. + * include/std/thread (_Callable constructor): Use forward. + * include/std/tuple: Don't specify explicit template args to move. + + * testsuite/20_util/forward/requirements/explicit_instantiation.cc: + Adjust signature. + * testsuite/20_util/tuple/swap.cc: Swap takes lvalue reference. + * testsuite/30_threads/shared_future/cons/copy.cc: Return rvalue + reference. + * testsuite/20_util/shared_ptr/assign/auto_ptr.cc, + testsuite/20_util/shared_ptr/assign/auto_ptr_neg.cc, + testsuite/20_util/shared_ptr/cons/auto_ptr.cc, + testsuite/20_util/shared_ptr/cons/auto_ptr_neg.cc, + testsuite/23_containers/forward_list/ext_pointer/operations/1.cc, + testsuite/23_containers/forward_list/ext_pointer/operations/5.cc, + testsuite/23_containers/forward_list/operations/1.cc, + testsuite/23_containers/forward_list/operations/5.cc: Use move. + * testsuite/23_containers/list/requirements/dr438/assign_neg.cc, + testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc, + testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc, + testsuite/23_containers/list/requirements/dr438/insert_neg.cc, + testsuite/30_threads/thread/cons/assign_neg.cc: Adjust line numbers. + 2009-07-31 Paolo Carlini PR libstdc++/40912 (partial) diff --git a/libstdc++-v3/include/bits/forward_list.h b/libstdc++-v3/include/bits/forward_list.h index 724d87b01b1..5158f2dac64 100644 --- a/libstdc++-v3/include/bits/forward_list.h +++ b/libstdc++-v3/include/bits/forward_list.h @@ -1057,7 +1057,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std) void splice_after(const_iterator __pos, forward_list&& __list, const_iterator __it) - { this->splice_after(__pos, __list, __it, __it._M_next()); } + { + this->splice_after(__pos, std::forward(__list), + __it, __it._M_next()); + } /** * @brief Insert range from another %forward_list. @@ -1146,7 +1149,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) */ void merge(forward_list&& __list) - { this->merge(__list, std::less<_Tp>()); } + { this->merge(std::forward(__list), std::less<_Tp>()); } /** * @brief Merge sorted lists according to comparison function. diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h index 129552f3705..eb7290053ed 100644 --- a/libstdc++-v3/include/bits/stl_iterator.h +++ b/libstdc++-v3/include/bits/stl_iterator.h @@ -913,7 +913,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) reference operator*() const - { return *_M_current; } + { return std::move(*_M_current); } pointer operator->() const @@ -973,7 +973,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) reference operator[](difference_type __n) const - { return _M_current[__n]; } + { return std::move(_M_current[__n]); } }; template diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h index f758baed5c9..2a6e58f798f 100644 --- a/libstdc++-v3/include/bits/stl_list.h +++ b/libstdc++-v3/include/bits/stl_list.h @@ -1027,7 +1027,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) insert(iterator __position, size_type __n, const value_type& __x) { list __tmp(__n, __x, _M_get_Node_allocator()); - splice(__position, __tmp); +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + splice(__position, std::move(__tmp)); +#else + splice(__position, __tmp); +#endif } /** @@ -1049,7 +1053,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) _InputIterator __last) { list __tmp(__first, __last, _M_get_Node_allocator()); +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + splice(__position, std::move(__tmp)); +#else splice(__position, __tmp); +#endif } /** diff --git a/libstdc++-v3/include/std/thread b/libstdc++-v3/include/std/thread index bf282cc0365..83b259d7949 100644 --- a/libstdc++-v3/include/std/thread +++ b/libstdc++-v3/include/std/thread @@ -126,7 +126,10 @@ namespace std template explicit thread(_Callable __f) - { _M_start_thread(_M_make_routine<_Callable>(__f)); } + { + _M_start_thread(_M_make_routine<_Callable> + (std::forward<_Callable>(__f))); + } template thread(_Callable&& __f, _Args&&... __args) diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple index 8dc8dcfc064..18cd89bca3b 100644 --- a/libstdc++-v3/include/std/tuple +++ b/libstdc++-v3/include/std/tuple @@ -164,7 +164,7 @@ namespace std : _Inherited(__in._M_tail()), _Base(__in._M_head()) { } _Tuple_impl(_Tuple_impl&& __in) - : _Inherited(std::move<_Inherited&&>(__in._M_tail())), + : _Inherited(std::move(__in._M_tail())), _Base(std::forward<_Head>(__in._M_head())) { } template @@ -173,8 +173,7 @@ namespace std template _Tuple_impl(_Tuple_impl<_Idx, _UElements...>&& __in) - : _Inherited(std::move:: - _Inherited&&>(__in._M_tail())), + : _Inherited(std::move(__in._M_tail())), _Base(std::forward:: _Base>(__in._M_head())) { } @@ -244,7 +243,7 @@ namespace std : _Inherited(static_cast(__in)) { } tuple(tuple&& __in) - : _Inherited(std::move<_Inherited>(__in)) { } + : _Inherited(static_cast<_Inherited&&>(__in)) { } template tuple(const tuple<_UElements...>& __in) @@ -253,7 +252,7 @@ namespace std template tuple(tuple<_UElements...>&& __in) - : _Inherited(std::move<_Tuple_impl<0, _UElements...> >(__in)) { } + : _Inherited(static_cast<_Tuple_impl<0, _UElements...>&&>(__in)) { } // XXX http://gcc.gnu.org/ml/libstdc++/2008-02/msg00047.html template @@ -327,7 +326,7 @@ namespace std : _Inherited(static_cast(__in)) { } tuple(tuple&& __in) - : _Inherited(std::move<_Inherited>(__in)) { } + : _Inherited(static_cast<_Inherited&&>(__in)) { } template tuple(const tuple<_U1, _U2>& __in) @@ -335,7 +334,7 @@ namespace std template tuple(tuple<_U1, _U2>&& __in) - : _Inherited(std::move<_Tuple_impl<0, _U1, _U2> >(__in)) { } + : _Inherited(static_cast<_Tuple_impl<0, _U1, _U2>&&>(__in)) { } template tuple(const pair<_U1, _U2>& __in) diff --git a/libstdc++-v3/testsuite/20_util/forward/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/forward/requirements/explicit_instantiation.cc index 8b14da23a95..88ba9e548af 100644 --- a/libstdc++-v3/testsuite/20_util/forward/requirements/explicit_instantiation.cc +++ b/libstdc++-v3/testsuite/20_util/forward/requirements/explicit_instantiation.cc @@ -28,5 +28,5 @@ namespace std { typedef short test_type; - template test_type&& forward(std::identity::type&&); + template test_type&& forward(test_type&&); } diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr.cc index e8c751bba5c..e2ec0786055 100644 --- a/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr.cc +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr.cc @@ -66,7 +66,7 @@ test01() std::shared_ptr a(new A); std::auto_ptr b(new B); - a = b; + a = std::move(b); VERIFY( a.get() != 0 ); VERIFY( b.get() == 0 ); VERIFY( A::ctor_count == 2 ); diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_neg.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_neg.cc index 155449438cf..b79a25b131c 100644 --- a/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_neg.cc +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_neg.cc @@ -36,7 +36,7 @@ test01() std::shared_ptr a; std::auto_ptr b; - a = b; // { dg-error "here" } + a = std::move(b); // { dg-error "here" } return 0; } diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr.cc index 9087e518ad9..eb5bb9590df 100644 --- a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr.cc +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr.cc @@ -33,7 +33,7 @@ test01() bool test __attribute__((unused)) = true; std::auto_ptr a(new A); - std::shared_ptr a2(a); + std::shared_ptr a2(std::move(a)); VERIFY( a.get() == 0 ); VERIFY( a2.get() != 0 ); VERIFY( a2.use_count() == 1 ); diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr_neg.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr_neg.cc index 3a946b5872b..e2ef60e3fbb 100644 --- a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr_neg.cc +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr_neg.cc @@ -34,7 +34,7 @@ test01() bool test __attribute__((unused)) = true; const std::auto_ptr a; - std::shared_ptr p(a); // { dg-error "no match" } + std::shared_ptr p(std::move(a)); // { dg-error "no match" } return 0; } diff --git a/libstdc++-v3/testsuite/20_util/tuple/swap.cc b/libstdc++-v3/testsuite/20_util/tuple/swap.cc index 6dab446bfe9..613e9c2ff1c 100644 --- a/libstdc++-v3/testsuite/20_util/tuple/swap.cc +++ b/libstdc++-v3/testsuite/20_util/tuple/swap.cc @@ -41,7 +41,7 @@ struct MoveOnly bool operator==(MoveOnly const& m) { return i == m.i; } - void swap(MoveOnly&& m) + void swap(MoveOnly& m) { std::swap(m.i, i); } int i; diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/1.cc b/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/1.cc index 0d9361a37d0..8b5afdd980b 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/1.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/1.cc @@ -39,7 +39,7 @@ test01() fwd_list_type x = {666.0, 777.0, 888.0}; - a.splice_after(posa, x); + a.splice_after(posa, std::move(x)); ++posa; VERIFY(*posa == 666.0); @@ -70,7 +70,7 @@ test02() ++endy; VERIFY(*endy == 14.0); - a.splice_after(posa, y, befy, endy); + a.splice_after(posa, std::move(y), befy, endy); VERIFY(*posa == 0.0); VERIFY(*befy == 10.0); @@ -95,7 +95,7 @@ test03() fwd_list_type::const_iterator posz = z.begin(); VERIFY(*posz == 42.0); - a.splice_after(posa, z, posz); + a.splice_after(posa, std::move(z), posz); VERIFY(*posa == 1.0); ++posa; VERIFY(*posa == 43.0); diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/5.cc b/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/5.cc index 434a9aaac95..13d15b39d12 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/5.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/5.cc @@ -37,7 +37,7 @@ test01() fwd_list_type a = {0.0, 1.0, 2.0, 3.0, 4.0}; fwd_list_type b = {1.0, 2.0, 3.0, 4.0, 4.0, 5.0}; - a.merge(b); + a.merge(std::move(b)); fwd_list_type r = {0.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 4.0, 5.0}; diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/operations/1.cc b/libstdc++-v3/testsuite/23_containers/forward_list/operations/1.cc index 1f86db9743f..5a996f3411e 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/operations/1.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/operations/1.cc @@ -34,7 +34,7 @@ test01() std::forward_list x = {666.0, 777.0, 888.0}; - a.splice_after(posa, x); + a.splice_after(posa, std::move(x)); ++posa; VERIFY(*posa == 666.0); @@ -63,7 +63,7 @@ test02() ++endy; VERIFY(*endy == 14.0); - a.splice_after(posa, y, befy, endy); + a.splice_after(posa, std::move(y), befy, endy); VERIFY(*posa == 0.0); VERIFY(*befy == 10.0); @@ -86,7 +86,7 @@ test03() std::forward_list::const_iterator posz = z.begin(); VERIFY(*posz == 42.0); - a.splice_after(posa, z, posz); + a.splice_after(posa, std::move(z), posz); VERIFY(*posa == 1.0); ++posa; VERIFY(*posa == 43.0); diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/operations/5.cc b/libstdc++-v3/testsuite/23_containers/forward_list/operations/5.cc index 05e3f844410..1291a269044 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/operations/5.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/operations/5.cc @@ -32,7 +32,7 @@ test01() std::forward_list a = {0.0, 1.0, 2.0, 3.0, 4.0}; std::forward_list b = {1.0, 2.0, 3.0, 4.0, 4.0, 5.0}; - a.merge(b); + a.merge(std::move(b)); std::forward_list r = {0.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 4.0, 5.0}; diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc index cd2b2994807..c0b6ea46be9 100644 --- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc @@ -18,7 +18,7 @@ // . // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1379 } +// { dg-error "no matching" "" { target *-*-* } 1387 } // { dg-excess-errors "" } #include diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc index cc2b419bd4e..0d27211a5f7 100644 --- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc @@ -18,7 +18,7 @@ // . // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1348 } +// { dg-error "no matching" "" { target *-*-* } 1356 } // { dg-excess-errors "" } #include diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc index d650a9ec102..bbf78080365 100644 --- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc @@ -18,7 +18,7 @@ // . // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1348 } +// { dg-error "no matching" "" { target *-*-* } 1356 } // { dg-excess-errors "" } #include diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc index ae9e63f704e..1e84b97d301 100644 --- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc @@ -18,7 +18,7 @@ // . // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1348 } +// { dg-error "no matching" "" { target *-*-* } 1356 } // { dg-excess-errors "" } #include diff --git a/libstdc++-v3/testsuite/30_threads/shared_future/cons/copy.cc b/libstdc++-v3/testsuite/30_threads/shared_future/cons/copy.cc index 16954a1d4c1..b1940fae3c7 100644 --- a/libstdc++-v3/testsuite/30_threads/shared_future/cons/copy.cc +++ b/libstdc++-v3/testsuite/30_threads/shared_future/cons/copy.cc @@ -25,7 +25,7 @@ #include #include -extern std::unique_future& get(); +extern std::unique_future&& get(); void test01() { diff --git a/libstdc++-v3/testsuite/30_threads/thread/cons/assign_neg.cc b/libstdc++-v3/testsuite/30_threads/thread/cons/assign_neg.cc index 7857e53bac7..1ea66ec9c81 100644 --- a/libstdc++-v3/testsuite/30_threads/thread/cons/assign_neg.cc +++ b/libstdc++-v3/testsuite/30_threads/thread/cons/assign_neg.cc @@ -32,4 +32,4 @@ void test01() } // { dg-error "used here" "" { target *-*-* } 31 } -// { dg-error "deleted function" "" { target *-*-* } 141 } +// { dg-error "deleted function" "" { target *-*-* } 144 } -- 2.30.2