This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[v3, v7-branch] libstdc++/26733


Hi,

tested x86-linux, committed to v7-branch.

Paolo.

/////////////////
2006-03-27  Paolo Carlini  <pcarlini@suse.de>

	PR libstdc++/26733
	* include/bits/basic_string.h (operator[]): Commit for real
	2005-05-19 mainline change, lost in a merge.
	* include/debug/deque (deque<>::deque(__gnu_cxx::__rvalref<>),
	deque<>::operator=(__gnu_cxx::__rvalref<>)): Add
	(struct __is_moveable<std::__debug::deque<> >): Add.
	* include/debug/list (list<>::list(__gnu_cxx::__rvalref<>),
	list<>::operator=(__gnu_cxx::__rvalref<>)): Add
	(struct __is_moveable<std::__debug::list<> >): Add.
	* include/debug/map.h (map<>::map(__gnu_cxx::__rvalref<>),
	map<>::operator=(__gnu_cxx::__rvalref<>)): Add.
	(struct __is_moveable<std::__debug::map<> >): Add.
	* include/debug/multimap.h (multimap<>::multimap(__gnu_cxx::
	__rvalref<>), multimap<>::operator=(__gnu_cxx::__rvalref<>)): Add.
	(struct __is_moveable<std::__debug::multimap<> >): Add.
	* include/debug/multiset.h (multiset<>::multiset(__gnu_cxx::
	__rvalref<>), multiset<>::operator=(__gnu_cxx::__rvalref<>)): Add
	(struct __is_moveable<std::__debug::multiset<> >): Add.
	* include/debug/set.h (set<>::set(__gnu_cxx::__rvalref<>),
	set<>::operator=(__gnu_cxx::__rvalref<>)): Add.
	(struct __is_moveable<std::__debug::set<> >): Add.
	* include/debug/vector (vector<>::vector(__gnu_cxx::
	__rvalref<>), vector<>::operator=(__gnu_cxx::__rvalref<>)): Add
	(struct __is_moveable<std::__debug::vector<> >): Add.
	* testsuite/23_containers/deque/resize/moveable.cc: In debug mode
	allow for one additional copy for each resize, due to the by value
	second argument.
	* testsuite/23_containers/vector/resize/moveable.cc: Likewise.
Index: include/bits/basic_string.h
===================================================================
--- include/bits/basic_string.h	(revision 112225)
+++ include/bits/basic_string.h	(working copy)
@@ -1,6 +1,6 @@
 // Components for manipulating sequences of characters -*- C++ -*-
 
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -494,7 +494,10 @@
       reference
       operator[](size_type __pos)
       {
-	_GLIBCXX_DEBUG_ASSERT(__pos < this->size());
+        // allow pos == size() as v3 extension:
+	_GLIBCXX_DEBUG_ASSERT(__pos <= size());
+        // but be strict in pedantic mode:
+	_GLIBCXX_DEBUG_PEDASSERT(__pos < size());
 	this->_M_leak();
 	return this->_M_data()[__pos];
       }
Index: include/debug/set.h
===================================================================
--- include/debug/set.h	(revision 112225)
+++ include/debug/set.h	(working copy)
@@ -1,6 +1,6 @@
 // Debugging set implementation -*- C++ -*-
 
-// Copyright (C) 2003, 2004, 2005
+// Copyright (C) 2003, 2004, 2005, 2006
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -82,21 +82,35 @@
 	: _Base(__gnu_debug::__check_valid_range(__first, __last), __last,
 		__comp, __a) { }
 
-      set(const set<_Key,_Compare,_Allocator>& __x)
+      set(const set& __x)
       : _Base(__x), _Safe_base() { }
 
-      set(const _Base& __x) : _Base(__x), _Safe_base() { }
+      set(const _Base& __x)
+      : _Base(__x), _Safe_base() { }
 
+      template<typename _Set>
+	set(__gnu_cxx::__rvalref<_Set> __x)
+	: _Base(__x), _Safe_base()
+        { this->_M_swap(__x.__ref); }
+
       ~set() { }
 
-      set<_Key,_Compare,_Allocator>&
-      operator=(const set<_Key,_Compare,_Allocator>& __x)
+      set&
+      operator=(const set& __x)
       {
 	*static_cast<_Base*>(this) = __x;
 	this->_M_invalidate_all();
 	return *this;
       }
 
+      template<typename _Set>
+        set&
+        operator=(__gnu_cxx::__rvalref<_Set> __x)
+        {
+	  swap(__x.__ref);
+	  return *this;
+	}
+
       using _Base::get_allocator;
 
       // iterators:
@@ -203,7 +217,7 @@
       }
 
       void
-      swap(set<_Key,_Compare,_Allocator>& __x)
+      swap(set& __x)
       {
 	_Base::swap(__x);
 	this->_M_swap(__x);
@@ -332,4 +346,12 @@
 } // namespace __debug
 } // namespace std
 
+_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
+
+  template<typename _Tp, typename _Alloc>
+    struct __is_moveable<std::__debug::set<_Tp, _Alloc> >
+    { static const bool __value = true; };
+
+_GLIBCXX_END_NAMESPACE
+
 #endif
Index: include/debug/multiset.h
===================================================================
--- include/debug/multiset.h	(revision 112225)
+++ include/debug/multiset.h	(working copy)
@@ -1,6 +1,6 @@
 // Debugging multiset implementation -*- C++ -*-
 
-// Copyright (C) 2003, 2004, 2005
+// Copyright (C) 2003, 2004, 2005, 2006
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -82,21 +82,35 @@
 	: _Base(__gnu_debug::__check_valid_range(__first, __last), __last,
 		__comp, __a) { }
 
-      multiset(const multiset<_Key,_Compare,_Allocator>& __x)
+      multiset(const multiset& __x)
       : _Base(__x), _Safe_base() { }
 
-      multiset(const _Base& __x) : _Base(__x), _Safe_base() { }
+      multiset(const _Base& __x)
+      : _Base(__x), _Safe_base() { }
 
+      template<typename _Multiset>
+	multiset(__gnu_cxx::__rvalref<_Multiset> __x)
+	: _Base(__x), _Safe_base()
+        { this->_M_swap(__x.__ref); }
+
       ~multiset() { }
 
-      multiset<_Key,_Compare,_Allocator>&
-      operator=(const multiset<_Key,_Compare,_Allocator>& __x)
+      multiset&
+      operator=(const multiset& __x)
       {
 	*static_cast<_Base*>(this) = __x;
 	this->_M_invalidate_all();
 	return *this;
       }
 
+      template<typename _Multiset>
+        multiset&
+        operator=(__gnu_cxx::__rvalref<_Multiset> __x)
+        {
+	  swap(__x.__ref);
+	  return *this;
+	}
+
       using _Base::get_allocator;
 
       // iterators:
@@ -198,7 +212,7 @@
       }
 
       void
-      swap(multiset<_Key,_Compare,_Allocator>& __x)
+      swap(multiset& __x)
       {
 	_Base::swap(__x);
 	this->_M_swap(__x);
@@ -327,4 +341,12 @@
 } // namespace __debug
 } // namespace std
 
+_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
+
+  template<typename _Tp, typename _Alloc>
+    struct __is_moveable<std::__debug::multiset<_Tp, _Alloc> >
+    { static const bool __value = true; };
+
+_GLIBCXX_END_NAMESPACE
+
 #endif
Index: include/debug/vector
===================================================================
--- include/debug/vector	(revision 112415)
+++ include/debug/vector	(working copy)
@@ -1,6 +1,6 @@
 // Debugging vector implementation -*- C++ -*-
 
-// Copyright (C) 2003, 2004, 2005
+// Copyright (C) 2003, 2004, 2005, 2006
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -87,17 +87,25 @@
 	  _M_guaranteed_capacity(0)
         { _M_update_guaranteed_capacity(); }
 
-      vector(const vector<_Tp,_Allocator>& __x)
+      vector(const vector& __x)
       : _Base(__x), _Safe_base(), _M_guaranteed_capacity(__x.size()) { }
 
       /// Construction from a release-mode vector
       vector(const _Base& __x)
       : _Base(__x), _Safe_base(), _M_guaranteed_capacity(__x.size()) { }
 
+      template<typename _Vector>
+	vector(__gnu_cxx::__rvalref<_Vector> __x)
+	: _Base(__x), _Safe_base(), _M_guaranteed_capacity(this->size())
+        { 
+	  this->_M_swap(__x.__ref);
+	  __x.__ref._M_guaranteed_capacity = 0;
+	}
+
       ~vector() { }
 
-      vector<_Tp,_Allocator>&
-      operator=(const vector<_Tp,_Allocator>& __x)
+      vector&
+      operator=(const vector& __x)
       {
 	static_cast<_Base&>(*this) = __x;
 	this->_M_invalidate_all();
@@ -105,6 +113,14 @@
 	return *this;
       }
 
+      template<typename _Vector>
+	vector&
+	operator=(__gnu_cxx::__rvalref<_Vector> __x)
+	{
+	  swap(__x.__ref);
+	  return *this;
+	}
+
       template<typename _InputIterator>
         void
         assign(_InputIterator __first, _InputIterator __last)
@@ -331,7 +347,7 @@
       }
 
       void
-      swap(vector<_Tp,_Allocator>& __x)
+      swap(vector& __x)
       {
 	_Base::swap(__x);
 	this->_M_swap(__x);
@@ -416,4 +432,12 @@
 } // namespace __debug
 } // namespace std
 
+_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
+
+  template<typename _Tp, typename _Alloc>
+    struct __is_moveable<std::__debug::vector<_Tp, _Alloc> >
+    { static const bool __value = true; };
+
+_GLIBCXX_END_NAMESPACE
+
 #endif
Index: include/debug/map.h
===================================================================
--- include/debug/map.h	(revision 112225)
+++ include/debug/map.h	(working copy)
@@ -1,6 +1,6 @@
 // Debugging map implementation -*- C++ -*-
 
-// Copyright (C) 2003, 2004, 2005
+// Copyright (C) 2003, 2004, 2005, 2006
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -84,20 +84,34 @@
 	: _Base(__gnu_debug::__check_valid_range(__first, __last), __last,
 		__comp, __a), _Safe_base() { }
 
-      map(const map<_Key,_Tp,_Compare,_Allocator>& __x)
+      map(const map& __x)
       : _Base(__x), _Safe_base() { }
 
-      map(const _Base& __x) : _Base(__x), _Safe_base() { }
+      map(const _Base& __x)
+      : _Base(__x), _Safe_base() { }
 
+      template<typename _Map>
+	map(__gnu_cxx::__rvalref<_Map> __x)
+	: _Base(__x), _Safe_base()
+        { this->_M_swap(__x.__ref); }
+
       ~map() { }
 
-      map<_Key,_Tp,_Compare,_Allocator>&
-      operator=(const map<_Key,_Tp,_Compare,_Allocator>& __x)
+      map&
+      operator=(const map& __x)
       {
 	*static_cast<_Base*>(this) = __x;
 	this->_M_invalidate_all();
 	return *this;
       }
+      
+      template<typename _Map>
+        map&
+        operator=(__gnu_cxx::__rvalref<_Map> __x)
+        {
+	  swap(__x.__ref);
+	  return *this;
+	}
 
       // _GLIBCXX_RESOLVE_LIB_DEFECTS
       // 133. map missing get_allocator()
@@ -213,7 +227,7 @@
       }
 
       void
-      swap(map<_Key,_Tp,_Compare,_Allocator>& __x)
+      swap(map& __x)
       {
 	_Base::swap(__x);
 	this->_M_swap(__x);
@@ -334,4 +348,12 @@
 } // namespace __debug
 } // namespace std
 
+_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
+
+  template<typename _Tp, typename _Alloc>
+    struct __is_moveable<std::__debug::map<_Tp, _Alloc> >
+    { static const bool __value = true; };
+
+_GLIBCXX_END_NAMESPACE
+
 #endif
Index: include/debug/deque
===================================================================
--- include/debug/deque	(revision 112225)
+++ include/debug/deque	(working copy)
@@ -1,6 +1,6 @@
 // Debugging deque implementation -*- C++ -*-
 
-// Copyright (C) 2003, 2004, 2005
+// Copyright (C) 2003, 2004, 2005, 2006
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -80,20 +80,35 @@
 	: _Base(__gnu_debug::__check_valid_range(__first, __last), __last, __a)
         { }
 
-      deque(const deque<_Tp,_Allocator>& __x) : _Base(__x), _Safe_base() { }
+      deque(const deque& __x)
+      : _Base(__x), _Safe_base() { }
 
-      deque(const _Base& __x) : _Base(__x), _Safe_base() { }
+      deque(const _Base& __x)
+      : _Base(__x), _Safe_base() { }
 
+      template<typename _Deque>
+	deque(__gnu_cxx::__rvalref<_Deque> __x)
+	: _Base(__x), _Safe_base()
+        { this->_M_swap(__x.__ref); }
+
       ~deque() { }
-
-      deque<_Tp,_Allocator>&
-      operator=(const deque<_Tp,_Allocator>& __x)
+      
+      deque&
+      operator=(const deque& __x)
       {
 	*static_cast<_Base*>(this) = __x;
 	this->_M_invalidate_all();
 	return *this;
       }
 
+      template<typename _Deque>
+        deque&
+        operator=(__gnu_cxx::__rvalref<_Deque> __x)
+        {
+	  swap(__x.__ref);	  
+	  return *this;
+	}
+
       template<class _InputIterator>
         void
         assign(_InputIterator __first, _InputIterator __last)
@@ -325,7 +340,7 @@
       }
 
       void
-      swap(deque<_Tp,_Allocator>& __x)
+      swap(deque& __x)
       {
 	_Base::swap(__x);
 	this->_M_swap(__x);
@@ -386,4 +401,12 @@
 } // namespace __debug
 } // namespace std
 
+_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
+
+  template<typename _Tp, typename _Alloc>
+    struct __is_moveable<std::__debug::deque<_Tp, _Alloc> >
+    { static const bool __value = true; };
+
+_GLIBCXX_END_NAMESPACE
+
 #endif
Index: include/debug/list
===================================================================
--- include/debug/list	(revision 112225)
+++ include/debug/list	(working copy)
@@ -81,10 +81,16 @@
       : _Base(__gnu_debug::__check_valid_range(__first, __last), __last, __a)
       { }
 
+      list(const list& __x)
+      : _Base(__x), _Safe_base() { }
 
-      list(const list& __x) : _Base(__x), _Safe_base() { }
+      list(const _Base& __x)
+      : _Base(__x), _Safe_base() { }
 
-      list(const _Base& __x) : _Base(__x), _Safe_base() { }
+      template<typename _List>
+	list(__gnu_cxx::__rvalref<_List> __x)
+	: _Base(__x), _Safe_base()
+        { this->_M_swap(__x.__ref); }
 
       ~list() { }
 
@@ -96,6 +102,14 @@
 	return *this;
       }
 
+      template<typename _List>
+        list&
+        operator=(__gnu_cxx::__rvalref<_List> __x)
+        {
+	  swap(__x.__ref);
+	  return *this;
+	}
+
       template<class _InputIterator>
         void
         assign(_InputIterator __first, _InputIterator __last)
@@ -506,4 +520,12 @@
 } // namespace __debug
 } // namespace std
 
+_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
+
+  template<typename _Tp, typename _Alloc>
+    struct __is_moveable<std::__debug::list<_Tp, _Alloc> >
+    { static const bool __value = true; };
+
+_GLIBCXX_END_NAMESPACE
+
 #endif
Index: include/debug/multimap.h
===================================================================
--- include/debug/multimap.h	(revision 112225)
+++ include/debug/multimap.h	(working copy)
@@ -1,6 +1,6 @@
 // Debugging multimap implementation -*- C++ -*-
 
-// Copyright (C) 2003, 2004, 2005
+// Copyright (C) 2003, 2004, 2005, 2006
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -84,21 +84,35 @@
       : _Base(__gnu_debug::__check_valid_range(__first, __last), __last,
 	      __comp, __a) { }
 
-      multimap(const multimap<_Key,_Tp,_Compare,_Allocator>& __x)
+      multimap(const multimap& __x)
       : _Base(__x), _Safe_base() { }
 
-      multimap(const _Base& __x) : _Base(__x), _Safe_base() { }
+      multimap(const _Base& __x)
+      : _Base(__x), _Safe_base() { }
 
+      template<typename _Multimap>
+	multimap(__gnu_cxx::__rvalref<_Multimap> __x)
+	: _Base(__x), _Safe_base()
+        { this->_M_swap(__x.__ref); }
+
       ~multimap() { }
 
-      multimap<_Key,_Tp,_Compare,_Allocator>&
-      operator=(const multimap<_Key,_Tp,_Compare,_Allocator>& __x)
+      multimap&
+      operator=(const multimap& __x)
       {
 	*static_cast<_Base*>(this) = __x;
 	this->_M_invalidate_all();
 	return *this;
       }
 
+      template<typename _Multimap>
+        multimap&
+        operator=(__gnu_cxx::__rvalref<_Multimap> __x)
+        {
+	  swap(__x.__ref);
+	  return *this;
+	}
+
       using _Base::get_allocator;
 
       // iterators:
@@ -200,7 +214,7 @@
       }
 
       void
-      swap(multimap<_Key,_Tp,_Compare,_Allocator>& __x)
+      swap(multimap& __x)
       {
 	_Base::swap(__x);
 	this->_M_swap(__x);
@@ -321,4 +335,12 @@
 } // namespace __debug
 } // namespace std
 
+_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
+
+  template<typename _Tp, typename _Alloc>
+    struct __is_moveable<std::__debug::multimap<_Tp, _Alloc> >
+    { static const bool __value = true; };
+
+_GLIBCXX_END_NAMESPACE
+
 #endif
Index: testsuite/23_containers/vector/resize/moveable.cc
===================================================================
--- testsuite/23_containers/vector/resize/moveable.cc	(revision 112225)
+++ testsuite/23_containers/vector/resize/moveable.cc	(working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2005 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -34,7 +34,7 @@
 // According to n1771, there should be two resizes, with and without
 // parameter. We only have one at present, whose second parameter defaults
 // to a default-constructed object.
-// These values are one higher than might be expected because internally
+// Also, the values are one higher than might be expected because internally
 // resize calls fill, which copies its input value in case it is already in
 // the vector when the vector isn't moved.
 void
@@ -48,14 +48,30 @@
   a.resize(98);
   a.resize(99);
   a.resize(100);
-  VERIFY(copycounter::copycount == 100 + 4);
+#ifndef _GLIBCXX_DEBUG
+  VERIFY( copycounter::copycount == 100 + 4 );
+#else
+  VERIFY( copycounter::copycount == 100 + 4 + 4 );
+#endif
   a.resize(99);
   a.resize(0);
-  VERIFY(copycounter::copycount == 100 + 4);
+#ifndef _GLIBCXX_DEBUG
+  VERIFY( copycounter::copycount == 100 + 4 );
+#else
+  VERIFY( copycounter::copycount == 100 + 4 + 6 );
+#endif
   a.resize(100);
-  VERIFY(copycounter::copycount == 200 + 5);
+#ifndef _GLIBCXX_DEBUG  
+  VERIFY( copycounter::copycount == 200 + 5 );
+#else
+  VERIFY( copycounter::copycount == 200 + 5 + 7 );
+#endif
   a.clear();
-  VERIFY(copycounter::copycount == 200 + 5);
+#ifndef _GLIBCXX_DEBUG
+  VERIFY( copycounter::copycount == 200 + 5 );
+#else
+  VERIFY( copycounter::copycount == 200 + 5 + 7 );
+#endif
 }
 
 
Index: testsuite/23_containers/deque/resize/moveable.cc
===================================================================
--- testsuite/23_containers/deque/resize/moveable.cc	(revision 112225)
+++ testsuite/23_containers/deque/resize/moveable.cc	(working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2005 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -46,15 +46,30 @@
   a.resize(98);
   a.resize(99);
   a.resize(100);
-  printf("%d\n", copycounter::copycount);
-  VERIFY(copycounter::copycount == 100);
+#ifndef _GLIBCXX_DEBUG
+  VERIFY( copycounter::copycount == 100 );
+#else
+  VERIFY( copycounter::copycount == 100 + 4 );
+#endif
   a.resize(99);
   a.resize(0);
-  VERIFY(copycounter::copycount == 100);
+#ifndef _GLIBCXX_DEBUG
+  VERIFY( copycounter::copycount == 100 );
+#else
+  VERIFY( copycounter::copycount == 100 + 6 );
+#endif
   a.resize(100);
-  VERIFY(copycounter::copycount == 200);
+#ifndef _GLIBCXX_DEBUG
+  VERIFY( copycounter::copycount == 200 );
+#else
+  VERIFY( copycounter::copycount == 200 + 7 );
+#endif
   a.clear();
-  VERIFY(copycounter::copycount == 200);
+#ifndef _GLIBCXX_DEBUG
+  VERIFY( copycounter::copycount == 200 );
+#else
+  VERIFY( copycounter::copycount == 200 + 7 );
+#endif
 }
 
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]