aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <pcarlini@suse.de>2007-10-06 02:33:12 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2007-10-06 02:33:12 +0000
commitf63bc637f68a42da874eb142f389c2c268c9c915 (patch)
treecf7d34bfda907f5960d08e1865f67e231d19820a
parent02c9a7a7fc4acde6e07f9050d4c4c30eec3103be (diff)
downloadgcc-f63bc637f68a42da874eb142f389c2c268c9c915.zip
gcc-f63bc637f68a42da874eb142f389c2c268c9c915.tar.gz
gcc-f63bc637f68a42da874eb142f389c2c268c9c915.tar.bz2
moveable.cc: Remove dg-require-rvalref.
2007-10-05 Paolo Carlini <pcarlini@suse.de> * 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 <pcarlini@suse.de> Chris Jefferson <chris@bubblescope.net> * include/bits/stl_iterator.h (class move_iterator, make_move_iterator): Add. Co-Authored-By: Chris Jefferson <chris@bubblescope.net> From-SVN: r129048
-rw-r--r--libstdc++-v3/ChangeLog17
-rw-r--r--libstdc++-v3/include/bits/stl_iterator.h169
-rw-r--r--libstdc++-v3/include/std/utility7
-rw-r--r--libstdc++-v3/testsuite/23_containers/deque/moveable.cc1
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/moveable.cc1
-rw-r--r--libstdc++-v3/testsuite/23_containers/map/moveable.cc1
-rw-r--r--libstdc++-v3/testsuite/23_containers/multimap/moveable.cc2
-rw-r--r--libstdc++-v3/testsuite/23_containers/multiset/moveable.cc1
-rw-r--r--libstdc++-v3/testsuite/23_containers/set/moveable.cc1
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/moveable.cc1
10 files changed, 191 insertions, 10 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index cfd6c2f..712cde5 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,20 @@
+2007-10-05 Paolo Carlini <pcarlini@suse.de>
+
+ * 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 <pcarlini@suse.de>
+ Chris Jefferson <chris@bubblescope.net>
+
+ * include/bits/stl_iterator.h (class move_iterator,
+ make_move_iterator): Add.
+
2007-10-04 Doug Kwan <dougkwan@google.com>
* 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 d7c0926..ac561ee 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<typename _Iterator>
+ 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<typename _Iter>
+ 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<typename _IteratorL, typename _IteratorR>
+ inline bool
+ operator==(const move_iterator<_IteratorL>& __x,
+ const move_iterator<_IteratorR>& __y)
+ { return __x.base() == __y.base(); }
+
+ template<typename _IteratorL, typename _IteratorR>
+ inline bool
+ operator!=(const move_iterator<_IteratorL>& __x,
+ const move_iterator<_IteratorR>& __y)
+ { return !(__x == __y); }
+
+ template<typename _IteratorL, typename _IteratorR>
+ inline bool
+ operator<(const move_iterator<_IteratorL>& __x,
+ const move_iterator<_IteratorR>& __y)
+ { return __x.base() < __y.base(); }
+
+ template<typename _IteratorL, typename _IteratorR>
+ inline bool
+ operator<=(const move_iterator<_IteratorL>& __x,
+ const move_iterator<_IteratorR>& __y)
+ { return !(__y < __x); }
+
+ template<typename _IteratorL, typename _IteratorR>
+ inline bool
+ operator>(const move_iterator<_IteratorL>& __x,
+ const move_iterator<_IteratorR>& __y)
+ { return __y < __x; }
+
+ template<typename _IteratorL, typename _IteratorR>
+ inline bool
+ operator>=(const move_iterator<_IteratorL>& __x,
+ const move_iterator<_IteratorR>& __y)
+ { return !(__x < __y); }
+
+ template<typename _IteratorL, typename _IteratorR>
+ inline typename move_iterator<_IteratorL>::difference_type
+ operator-(const move_iterator<_IteratorL>& __x,
+ const move_iterator<_IteratorR>& __y)
+ { return __x.base() - __y.base(); }
+
+ template<typename _Iterator>
+ inline move_iterator<_Iterator>
+ operator+(typename move_iterator<_Iterator>::difference_type __n,
+ const move_iterator<_Iterator>& __x)
+ { return __x + __n; }
+
+ template<typename _Iterator>
+ 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 e9376dc..5020b95 100644
--- a/libstdc++-v3/include/std/utility
+++ b/libstdc++-v3/include/std/utility
@@ -87,8 +87,8 @@
#include <type_traits>
-namespace std
-{
+_GLIBCXX_BEGIN_NAMESPACE(std)
+
// 20.2.2, forward/move
template<typename _Tp>
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 e1fe8ae..ae532de 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 19b5ea1..d3f1031 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 ca2a2f3..5244708 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 75bfd43..87796f4 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 <map>
+#include <utility>
#include <testsuite_hooks.h>
int main()
diff --git a/libstdc++-v3/testsuite/23_containers/multiset/moveable.cc b/libstdc++-v3/testsuite/23_containers/multiset/moveable.cc
index 5cd4f32..c3ca111 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 81ca041..b85ae58 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 289a433..df825f3 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.