From f63bc637f68a42da874eb142f389c2c268c9c915 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Sat, 6 Oct 2007 02:33:12 +0000 Subject: [PATCH] moveable.cc: Remove dg-require-rvalref. 2007-10-05 Paolo Carlini * testsuite/23_containers/map/moveable.cc: Remove dg-require-rvalref. * testsuite/23_containers/multimap/moveable.cc: Likewise. * testsuite/23_containers/set/moveable.cc: Likewise. * testsuite/23_containers/multiset/moveable.cc: Likewise. * testsuite/23_containers/deque/moveable.cc: Likewise. * testsuite/23_containers/list/moveable.cc: Likewise. * testsuite/23_containers/vector/moveable.cc: Likewise. * include/std/utility: Use _GLIBCXX_BEGIN_NAMESPACE. 2007-10-05 Paolo Carlini Chris Jefferson * include/bits/stl_iterator.h (class move_iterator, make_move_iterator): Add. Co-Authored-By: Chris Jefferson From-SVN: r129048 --- libstdc++-v3/ChangeLog | 17 ++ libstdc++-v3/include/bits/stl_iterator.h | 169 ++++++++++++++++++ libstdc++-v3/include/std/utility | 7 +- .../testsuite/23_containers/deque/moveable.cc | 1 - .../testsuite/23_containers/list/moveable.cc | 1 - .../testsuite/23_containers/map/moveable.cc | 1 - .../23_containers/multimap/moveable.cc | 2 +- .../23_containers/multiset/moveable.cc | 1 - .../testsuite/23_containers/set/moveable.cc | 1 - .../23_containers/vector/moveable.cc | 1 - 10 files changed, 191 insertions(+), 10 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index cfd6c2f54be..712cde5d5d1 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,20 @@ +2007-10-05 Paolo Carlini + + * testsuite/23_containers/map/moveable.cc: Remove dg-require-rvalref. + * testsuite/23_containers/multimap/moveable.cc: Likewise. + * testsuite/23_containers/set/moveable.cc: Likewise. + * testsuite/23_containers/multiset/moveable.cc: Likewise. + * testsuite/23_containers/deque/moveable.cc: Likewise. + * testsuite/23_containers/list/moveable.cc: Likewise. + * testsuite/23_containers/vector/moveable.cc: Likewise. + * include/std/utility: Use _GLIBCXX_BEGIN_NAMESPACE. + +2007-10-05 Paolo Carlini + Chris Jefferson + + * include/bits/stl_iterator.h (class move_iterator, + make_move_iterator): Add. + 2007-10-04 Doug Kwan * include/ext/concurrent.h (class __mutex, diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h index d7c09260234..ac561eee351 100644 --- a/libstdc++-v3/include/bits/stl_iterator.h +++ b/libstdc++-v3/include/bits/stl_iterator.h @@ -826,4 +826,173 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) _GLIBCXX_END_NAMESPACE +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + +_GLIBCXX_BEGIN_NAMESPACE(std) + + // 24.4.3 Move iterators + /** + * @if maint + * Class template move_iterator is an iterator adapter with the same + * behavior as the underlying iterator except that its dereference + * operator implicitly converts the value returned by the underlying + * iterator's dereference operator to an rvalue reference. Some + * generic algorithms can be called with move iterators to replace + * copying with moving. + * @endif + */ + template + class move_iterator + { + protected: + _Iterator _M_current; + + public: + typedef _Iterator iterator_type; + typedef typename iterator_traits<_Iterator>::difference_type + difference_type; + typedef typename iterator_traits<_Iterator>::pointer pointer; + typedef typename iterator_traits<_Iterator>::value_type value_type; + typedef typename iterator_traits<_Iterator>::iterator_category + iterator_category; + typedef value_type&& reference; + + public: + move_iterator() + : _M_current() { } + + explicit + move_iterator(iterator_type __i) + : _M_current(__i) { } + + template + move_iterator(const move_iterator<_Iter>& __i) + : _M_current(__i.base()) { } + + iterator_type + base() const + { return _M_current; } + + reference + operator*() const + { return *_M_current; } + + pointer + operator->() const + { return _M_current; } + + move_iterator& + operator++() + { + ++_M_current; + return *this; + } + + move_iterator + operator++(int) + { + move_iterator __tmp = *this; + ++_M_current; + return __tmp; + } + + move_iterator& + operator--() + { + --_M_current; + return *this; + } + + move_iterator + operator--(int) + { + move_iterator __tmp = *this; + --_M_current; + return __tmp; + } + + move_iterator + operator+(difference_type __n) const + { return move_iterator(_M_current + __n); } + + move_iterator& + operator+=(difference_type __n) + { + _M_current += __n; + return *this; + } + + move_iterator + operator-(difference_type __n) const + { return move_iterator(_M_current - __n); } + + move_iterator& + operator-=(difference_type __n) + { + _M_current -= __n; + return *this; + } + + reference + operator[](difference_type __n) const + { return _M_current[__n]; } + }; + + template + inline bool + operator==(const move_iterator<_IteratorL>& __x, + const move_iterator<_IteratorR>& __y) + { return __x.base() == __y.base(); } + + template + inline bool + operator!=(const move_iterator<_IteratorL>& __x, + const move_iterator<_IteratorR>& __y) + { return !(__x == __y); } + + template + inline bool + operator<(const move_iterator<_IteratorL>& __x, + const move_iterator<_IteratorR>& __y) + { return __x.base() < __y.base(); } + + template + inline bool + operator<=(const move_iterator<_IteratorL>& __x, + const move_iterator<_IteratorR>& __y) + { return !(__y < __x); } + + template + inline bool + operator>(const move_iterator<_IteratorL>& __x, + const move_iterator<_IteratorR>& __y) + { return __y < __x; } + + template + inline bool + operator>=(const move_iterator<_IteratorL>& __x, + const move_iterator<_IteratorR>& __y) + { return !(__x < __y); } + + template + inline typename move_iterator<_IteratorL>::difference_type + operator-(const move_iterator<_IteratorL>& __x, + const move_iterator<_IteratorR>& __y) + { return __x.base() - __y.base(); } + + template + inline move_iterator<_Iterator> + operator+(typename move_iterator<_Iterator>::difference_type __n, + const move_iterator<_Iterator>& __x) + { return __x + __n; } + + template + inline move_iterator<_Iterator> + make_move_iterator(const _Iterator& __i) + { return move_iterator<_Iterator>(__i); } + +_GLIBCXX_END_NAMESPACE + +#endif // __GXX_EXPERIMENTAL_CXX0X__ + #endif diff --git a/libstdc++-v3/include/std/utility b/libstdc++-v3/include/std/utility index e9376dc8c70..5020b95b4f8 100644 --- a/libstdc++-v3/include/std/utility +++ b/libstdc++-v3/include/std/utility @@ -87,8 +87,8 @@ #include -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + // 20.2.2, forward/move template struct identity @@ -105,7 +105,8 @@ namespace std inline typename std::remove_reference<_Tp>::type&& move(_Tp&& __t) { return __t; } -} + +_GLIBCXX_END_NAMESPACE #endif diff --git a/libstdc++-v3/testsuite/23_containers/deque/moveable.cc b/libstdc++-v3/testsuite/23_containers/deque/moveable.cc index e1fe8aea6ac..ae532de9780 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/moveable.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/moveable.cc @@ -1,4 +1,3 @@ -// { dg-require-rvalref "" } // { dg-options "-std=gnu++0x" } // Copyright (C) 2005, 2007 Free Software Foundation, Inc. diff --git a/libstdc++-v3/testsuite/23_containers/list/moveable.cc b/libstdc++-v3/testsuite/23_containers/list/moveable.cc index 19b5ea111ce..d3f1031f91f 100644 --- a/libstdc++-v3/testsuite/23_containers/list/moveable.cc +++ b/libstdc++-v3/testsuite/23_containers/list/moveable.cc @@ -1,4 +1,3 @@ -// { dg-require-rvalref "" } // { dg-options "-std=gnu++0x" } // Copyright (C) 2005, 2007 Free Software Foundation, Inc. diff --git a/libstdc++-v3/testsuite/23_containers/map/moveable.cc b/libstdc++-v3/testsuite/23_containers/map/moveable.cc index ca2a2f305bf..52447083b2e 100644 --- a/libstdc++-v3/testsuite/23_containers/map/moveable.cc +++ b/libstdc++-v3/testsuite/23_containers/map/moveable.cc @@ -1,4 +1,3 @@ -// { dg-require-rvalref "" } // { dg-options "-std=gnu++0x" } // Copyright (C) 2005, 2007 Free Software Foundation, Inc. diff --git a/libstdc++-v3/testsuite/23_containers/multimap/moveable.cc b/libstdc++-v3/testsuite/23_containers/multimap/moveable.cc index 75bfd433ce3..87796f496f3 100644 --- a/libstdc++-v3/testsuite/23_containers/multimap/moveable.cc +++ b/libstdc++-v3/testsuite/23_containers/multimap/moveable.cc @@ -1,4 +1,3 @@ -// { dg-require-rvalref "" } // { dg-options "-std=gnu++0x" } // Copyright (C) 2005, 2007 Free Software Foundation, Inc. @@ -33,6 +32,7 @@ // this test may begin to fail. #include +#include #include int main() diff --git a/libstdc++-v3/testsuite/23_containers/multiset/moveable.cc b/libstdc++-v3/testsuite/23_containers/multiset/moveable.cc index 5cd4f3244e1..c3ca111804d 100644 --- a/libstdc++-v3/testsuite/23_containers/multiset/moveable.cc +++ b/libstdc++-v3/testsuite/23_containers/multiset/moveable.cc @@ -1,4 +1,3 @@ -// { dg-require-rvalref "" } // { dg-options "-std=gnu++0x" } // Copyright (C) 2005, 2007 Free Software Foundation, Inc. diff --git a/libstdc++-v3/testsuite/23_containers/set/moveable.cc b/libstdc++-v3/testsuite/23_containers/set/moveable.cc index 81ca041f6be..b85ae58ba06 100644 --- a/libstdc++-v3/testsuite/23_containers/set/moveable.cc +++ b/libstdc++-v3/testsuite/23_containers/set/moveable.cc @@ -1,4 +1,3 @@ -// { dg-require-rvalref "" } // { dg-options "-std=gnu++0x" } // Copyright (C) 2005, 2007 Free Software Foundation, Inc. diff --git a/libstdc++-v3/testsuite/23_containers/vector/moveable.cc b/libstdc++-v3/testsuite/23_containers/vector/moveable.cc index 289a4333f12..df825f3d007 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/moveable.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/moveable.cc @@ -1,4 +1,3 @@ -// { dg-require-rvalref "" } // { dg-options "-std=gnu++0x" } // Copyright (C) 2005, 2007 Free Software Foundation, Inc. -- 2.30.2