Commit 6b592ab3 by Paolo Carlini Committed by Paolo Carlini

set.h: Protect move assignment operator vs self assignment.

2010-01-08  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/debug/set.h: Protect move assignment operator vs self
	assignment.
	* include/debug/unordered_map: Likewise.
 	* include/debug/multiset.h: Likewise.
 	* include/debug/vector: Likewise.
	* include/debug/unordered_set: Likewise.
	* include/debug/deque: Likewise.
	* include/debug/map.h: Likewise.
	* include/debug/list: Likewise.
	* include/debug/multimap.h: Likewise.
	* include/tr1_impl/unordered_map: Likewise.
	* include/tr1_impl/unordered_set: Likewise.
	* include/profile/set.h: Likewise.
	* include/profile/unordered_map: Likewise.
	* include/profile/multiset.h: Likewise.
	* include/profile/unordered_set: Likewise.
	* include/profile/vector: Likewise.
	* include/profile/deque: Likewise.
	* include/profile/map.h: Likewise.
	* include/profile/list: Likewise.
	* include/profile/multimap.h: Likewise.
	* include/ext/vstring.h: Likewise.
	* include/bits/stl_list.h: Likewise.
	* include/bits/stl_map.h: Likewise.
	* include/bits/stl_set.h: Likewise.
	* include/bits/stl_multimap.h: Likewise.
	* include/bits/stl_vector.h: Likewise.
	* include/bits/stl_deque.h: Likewise.
	* include/bits/stl_multiset.h: Likewise.
	* include/ext/vstring.h: Use clear(). 
	* testsuite/ext/vstring/cons/self_move_assign.cc: New.
	* testsuite/23_containers/unordered_map/cons/self_move_assign.cc:
	Likewise.
	* testsuite/23_containers/multimap/cons/self_move_assign.cc: Likewise.
	* testsuite/23_containers/set/cons/self_move_assign.cc: Likewise.
	* testsuite/23_containers/unordered_multimap/cons/
	self_move_assign.cc: Likewise.
	* testsuite/23_containers/forward_list/cons/self_move_assign.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/cons/self_move_assign.cc:
	Likewise.
 	* testsuite/23_containers/vector/cons/self_move_assign.cc: Likewise.
	* testsuite/23_containers/deque/cons/self_move_assign.cc: Likewise.
	* testsuite/23_containers/multiset/cons/self_move_assign.cc: Likewise.
	* testsuite/23_containers/list/cons/self_move_assign.cc: Likewise.
	* testsuite/23_containers/unordered_multiset/cons/
	self_move_assign.cc: Likewise.
	* testsuite/23_containers/map/cons/self_move_assign.cc: Likewise.

	* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc:
	Adjust dg-error line numbers.
 	* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
	Likewise.
 	* testsuite/23_containers/vector/requirements/dr438/
	constructor_1_neg.cc: Likewise.
	* testsuite/23_containers/vector/requirements/dr438/
	constructor_2_neg.cc: Likewise.
	* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc:
	Likewise.
	* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc:
	Likewise.
	* testsuite/23_containers/deque/requirements/dr438/
	constructor_1_neg.cc: Likewise.
	* testsuite/23_containers/deque/requirements/dr438/
	constructor_2_neg.cc: Likewise.
	* testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
	Likewise.
	* testsuite/23_containers/list/requirements/dr438/insert_neg.cc:
	Likewise.
	* testsuite/23_containers/list/requirements/dr438/
	constructor_1_neg.cc: Likewise.
	* testsuite/23_containers/list/requirements/dr438/
	constructor_2_neg.cc: Likewise.

	* testsuite/ext/vstring/moveable.cc: Move to...
	* testsuite/ext/vstring/cons/moveable.cc: ... here.
	* testsuite/23_containers/unordered_map/moveable.cc: Move to...
	* testsuite/23_containers/unordered_map/cons/moveable.cc ... here.
	* testsuite/23_containers/multimap/moveable.cc: Move to...
	* testsuite/23_containers/multimap/cons/moveable.cc: ... here.
	* testsuite/23_containers/set/moveable.cc: Move to...
	* testsuite/23_containers/set/cons/moveable.cc: ... here.
	* testsuite/23_containers/unordered_multimap/moveable.cc: Move to...
	* testsuite/23_containers/unordered_multimap/cons/moveable.cc:
	... here.
	* testsuite/23_containers/forward_list/moveable.cc: Move to...
	* testsuite/23_containers/forward_list/cons/moveable.cc: ... here.
	* testsuite/23_containers/unordered_set/moveable.cc Move to...
	* testsuite/23_containers/unordered_set/moveable.cc: ... here.
	* testsuite/23_containers/vector/cons/moveable.cc Move to...
	* testsuite/23_containers/vector/cons/moveable2.cc: ... this.
	* testsuite/23_containers/deque/cons/moveable.cc Move to...
	* testsuite/23_containers/deque/cons/moveable2.cc: ... this.
	* testsuite/23_containers/multiset/moveable.cc Move to...
	* testsuite/23_containers/multiset/cons/moveable.cc: ... here.
	* testsuite/23_containers/list/moveable.h Move to...
	* testsuite/23_containers/list/cons/moveable.h: ... here.
	* testsuite/23_containers/list/moveable.cc Move to...
	* testsuite/23_containers/list/cons/moveable.cc: ... here.
	* testsuite/23_containers/unordered_multiset/moveable.cc Move to...
	* testsuite/23_containers/unordered_multiset/cons/moveable.cc:
	... here.
	* testsuite/23_containers/map/moveable.cc Move to...
	* testsuite/23_containers/map/cons/moveable.cc: ... here.
	* testsuite/23_containers/vector/moveable.cc: Move to...
	* testsuite/23_containers/vector/cons/moveable.cc: ... here.
	* testsuite/23_containers/deque/moveable.cc: Move to...
	* testsuite/23_containers/deque/cons/moveable.cc: ... here.

From-SVN: r155754
parent 06cced6c
2010-01-08 Paolo Carlini <paolo.carlini@oracle.com> 2010-01-08 Paolo Carlini <paolo.carlini@oracle.com>
* include/debug/set.h: Protect move assignment operator vs self
assignment.
* include/debug/unordered_map: Likewise.
* include/debug/multiset.h: Likewise.
* include/debug/vector: Likewise.
* include/debug/unordered_set: Likewise.
* include/debug/deque: Likewise.
* include/debug/map.h: Likewise.
* include/debug/list: Likewise.
* include/debug/multimap.h: Likewise.
* include/tr1_impl/unordered_map: Likewise.
* include/tr1_impl/unordered_set: Likewise.
* include/profile/set.h: Likewise.
* include/profile/unordered_map: Likewise.
* include/profile/multiset.h: Likewise.
* include/profile/unordered_set: Likewise.
* include/profile/vector: Likewise.
* include/profile/deque: Likewise.
* include/profile/map.h: Likewise.
* include/profile/list: Likewise.
* include/profile/multimap.h: Likewise.
* include/ext/vstring.h: Likewise.
* include/bits/stl_list.h: Likewise.
* include/bits/stl_map.h: Likewise.
* include/bits/stl_set.h: Likewise.
* include/bits/stl_multimap.h: Likewise.
* include/bits/stl_vector.h: Likewise.
* include/bits/stl_deque.h: Likewise.
* include/bits/stl_multiset.h: Likewise.
* include/ext/vstring.h: Use clear().
* testsuite/ext/vstring/cons/self_move_assign.cc: New.
* testsuite/23_containers/unordered_map/cons/self_move_assign.cc:
Likewise.
* testsuite/23_containers/multimap/cons/self_move_assign.cc: Likewise.
* testsuite/23_containers/set/cons/self_move_assign.cc: Likewise.
* testsuite/23_containers/unordered_multimap/cons/
self_move_assign.cc: Likewise.
* testsuite/23_containers/forward_list/cons/self_move_assign.cc:
Likewise.
* testsuite/23_containers/unordered_set/cons/self_move_assign.cc:
Likewise.
* testsuite/23_containers/vector/cons/self_move_assign.cc: Likewise.
* testsuite/23_containers/deque/cons/self_move_assign.cc: Likewise.
* testsuite/23_containers/multiset/cons/self_move_assign.cc: Likewise.
* testsuite/23_containers/list/cons/self_move_assign.cc: Likewise.
* testsuite/23_containers/unordered_multiset/cons/
self_move_assign.cc: Likewise.
* testsuite/23_containers/map/cons/self_move_assign.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc:
Adjust dg-error line numbers.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc:
Likewise.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
Likewise.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/list/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/list/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/ext/vstring/moveable.cc: Move to...
* testsuite/ext/vstring/cons/moveable.cc: ... here.
* testsuite/23_containers/unordered_map/moveable.cc: Move to...
* testsuite/23_containers/unordered_map/cons/moveable.cc ... here.
* testsuite/23_containers/multimap/moveable.cc: Move to...
* testsuite/23_containers/multimap/cons/moveable.cc: ... here.
* testsuite/23_containers/set/moveable.cc: Move to...
* testsuite/23_containers/set/cons/moveable.cc: ... here.
* testsuite/23_containers/unordered_multimap/moveable.cc: Move to...
* testsuite/23_containers/unordered_multimap/cons/moveable.cc:
... here.
* testsuite/23_containers/forward_list/moveable.cc: Move to...
* testsuite/23_containers/forward_list/cons/moveable.cc: ... here.
* testsuite/23_containers/unordered_set/moveable.cc Move to...
* testsuite/23_containers/unordered_set/moveable.cc: ... here.
* testsuite/23_containers/vector/cons/moveable.cc Move to...
* testsuite/23_containers/vector/cons/moveable2.cc: ... this.
* testsuite/23_containers/deque/cons/moveable.cc Move to...
* testsuite/23_containers/deque/cons/moveable2.cc: ... this.
* testsuite/23_containers/multiset/moveable.cc Move to...
* testsuite/23_containers/multiset/cons/moveable.cc: ... here.
* testsuite/23_containers/list/moveable.h Move to...
* testsuite/23_containers/list/cons/moveable.h: ... here.
* testsuite/23_containers/list/moveable.cc Move to...
* testsuite/23_containers/list/cons/moveable.cc: ... here.
* testsuite/23_containers/unordered_multiset/moveable.cc Move to...
* testsuite/23_containers/unordered_multiset/cons/moveable.cc:
... here.
* testsuite/23_containers/map/moveable.cc Move to...
* testsuite/23_containers/map/cons/moveable.cc: ... here.
* testsuite/23_containers/vector/moveable.cc: Move to...
* testsuite/23_containers/vector/cons/moveable.cc: ... here.
* testsuite/23_containers/deque/moveable.cc: Move to...
* testsuite/23_containers/deque/cons/moveable.cc: ... here.
2010-01-08 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/42573 PR libstdc++/42573
* include/bits/allocator.h (struct __shrink_to_fit): Add. * include/bits/allocator.h (struct __shrink_to_fit): Add.
* include/bits/stl_deque.h (deque<>::shrink_to_fit): Add. * include/bits/stl_deque.h (deque<>::shrink_to_fit): Add.
......
...@@ -884,9 +884,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -884,9 +884,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
deque& deque&
operator=(deque&& __x) operator=(deque&& __x)
{ {
// NB: DR 675. if (this != &__x)
this->clear(); {
this->swap(__x); // NB: DR 675.
this->clear();
this->swap(__x);
}
return *this; return *this;
} }
......
// List implementation -*- C++ -*- // List implementation -*- C++ -*-
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
// Free Software Foundation, Inc. // Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
...@@ -606,9 +606,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -606,9 +606,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
list& list&
operator=(list&& __x) operator=(list&& __x)
{ {
// NB: DR 675. if (this != &__x)
this->clear(); {
this->swap(__x); // NB: DR 675.
this->clear();
this->swap(__x);
}
return *this; return *this;
} }
......
// Map implementation -*- C++ -*- // Map implementation -*- C++ -*-
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
// Free Software Foundation, Inc. // Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
...@@ -265,9 +265,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -265,9 +265,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
map& map&
operator=(map&& __x) operator=(map&& __x)
{ {
// NB: DR 675. if (this != &__x)
this->clear(); {
this->swap(__x); // NB: DR 675.
this->clear();
this->swap(__x);
}
return *this; return *this;
} }
......
// Multimap implementation -*- C++ -*- // Multimap implementation -*- C++ -*-
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
// Free Software Foundation, Inc. // Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
...@@ -262,9 +262,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -262,9 +262,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
multimap& multimap&
operator=(multimap&& __x) operator=(multimap&& __x)
{ {
// NB: DR 675. if (this != &__x)
this->clear(); {
this->swap(__x); // NB: DR 675.
this->clear();
this->swap(__x);
}
return *this; return *this;
} }
......
// Multiset implementation -*- C++ -*- // Multiset implementation -*- C++ -*-
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
// Free Software Foundation, Inc. // Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
...@@ -234,9 +234,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -234,9 +234,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
multiset& multiset&
operator=(multiset&& __x) operator=(multiset&& __x)
{ {
// NB: DR 675. if (this != &__x)
this->clear(); {
this->swap(__x); // NB: DR 675.
this->clear();
this->swap(__x);
}
return *this; return *this;
} }
......
// Set implementation -*- C++ -*- // Set implementation -*- C++ -*-
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
// Free Software Foundation, Inc. // Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
...@@ -241,9 +241,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -241,9 +241,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
set& set&
operator=(set&& __x) operator=(set&& __x)
{ {
// NB: DR 675. if (this != &__x)
this->clear(); {
this->swap(__x); // NB: DR 675.
this->clear();
this->swap(__x);
}
return *this; return *this;
} }
......
...@@ -335,9 +335,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -335,9 +335,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
vector& vector&
operator=(vector&& __x) operator=(vector&& __x)
{ {
// NB: DR 675. if (this != &__x)
this->clear(); {
this->swap(__x); // NB: DR 675.
this->clear();
this->swap(__x);
}
return *this; return *this;
} }
......
...@@ -110,9 +110,12 @@ namespace __debug ...@@ -110,9 +110,12 @@ namespace __debug
deque& deque&
operator=(deque&& __x) operator=(deque&& __x)
{ {
// NB: DR 675. if (this != &__x)
clear(); {
swap(__x); // NB: DR 675.
clear();
swap(__x);
}
return *this; return *this;
} }
......
...@@ -112,9 +112,12 @@ namespace __debug ...@@ -112,9 +112,12 @@ namespace __debug
list& list&
operator=(list&& __x) operator=(list&& __x)
{ {
// NB: DR 675. if (this != &__x)
clear(); {
swap(__x); // NB: DR 675.
clear();
swap(__x);
}
return *this; return *this;
} }
......
...@@ -115,9 +115,12 @@ namespace __debug ...@@ -115,9 +115,12 @@ namespace __debug
map& map&
operator=(map&& __x) operator=(map&& __x)
{ {
// NB: DR 675. if (this != &__x)
clear(); {
swap(__x); // NB: DR 675.
clear();
swap(__x);
}
return *this; return *this;
} }
......
...@@ -116,9 +116,12 @@ namespace __debug ...@@ -116,9 +116,12 @@ namespace __debug
multimap& multimap&
operator=(multimap&& __x) operator=(multimap&& __x)
{ {
// NB: DR 675. if (this != &__x)
clear(); {
swap(__x); // NB: DR 675.
clear();
swap(__x);
}
return *this; return *this;
} }
......
...@@ -113,9 +113,12 @@ namespace __debug ...@@ -113,9 +113,12 @@ namespace __debug
multiset& multiset&
operator=(multiset&& __x) operator=(multiset&& __x)
{ {
// NB: DR 675. if (this != &__x)
clear(); {
swap(__x); // NB: DR 675.
clear();
swap(__x);
}
return *this; return *this;
} }
......
...@@ -113,9 +113,12 @@ namespace __debug ...@@ -113,9 +113,12 @@ namespace __debug
set& set&
operator=(set&& __x) operator=(set&& __x)
{ {
// NB: DR 675. if (this != &__x)
clear(); {
swap(__x); // NB: DR 675.
clear();
swap(__x);
}
return *this; return *this;
} }
......
// Debugging unordered_map/unordered_multimap implementation -*- C++ -*- // Debugging unordered_map/unordered_multimap implementation -*- C++ -*-
// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 // Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
// Free Software Foundation, Inc. // Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
...@@ -115,9 +115,12 @@ namespace __debug ...@@ -115,9 +115,12 @@ namespace __debug
unordered_map& unordered_map&
operator=(unordered_map&& __x) operator=(unordered_map&& __x)
{ {
// NB: DR 675. if (this != &__x)
clear(); {
swap(__x); // NB: DR 675.
clear();
swap(__x);
}
return *this; return *this;
} }
...@@ -388,9 +391,12 @@ namespace __debug ...@@ -388,9 +391,12 @@ namespace __debug
unordered_multimap& unordered_multimap&
operator=(unordered_multimap&& __x) operator=(unordered_multimap&& __x)
{ {
// NB: DR 675. if (this != &__x)
clear(); {
swap(__x); // NB: DR 675.
clear();
swap(__x);
}
return *this; return *this;
} }
......
// Debugging unordered_set/unordered_multiset implementation -*- C++ -*- // Debugging unordered_set/unordered_multiset implementation -*- C++ -*-
// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 // Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
// Free Software Foundation, Inc. // Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
...@@ -115,9 +115,12 @@ namespace __debug ...@@ -115,9 +115,12 @@ namespace __debug
unordered_set& unordered_set&
operator=(unordered_set&& __x) operator=(unordered_set&& __x)
{ {
// NB: DR 675. if (this != &__x)
clear(); {
swap(__x); // NB: DR 675.
clear();
swap(__x);
}
return *this; return *this;
} }
......
...@@ -124,9 +124,12 @@ namespace __debug ...@@ -124,9 +124,12 @@ namespace __debug
vector& vector&
operator=(vector&& __x) operator=(vector&& __x)
{ {
// NB: DR 675. if (this != &__x)
clear(); {
swap(__x); // NB: DR 675.
clear();
swap(__x);
}
return *this; return *this;
} }
......
...@@ -261,7 +261,10 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -261,7 +261,10 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
operator=(__versa_string&& __str) operator=(__versa_string&& __str)
{ {
if (this != &__str) if (this != &__str)
this->swap(__str); {
this->clear();
this->swap(__str);
}
return *this; return *this;
} }
......
...@@ -102,9 +102,12 @@ namespace __profile ...@@ -102,9 +102,12 @@ namespace __profile
deque& deque&
operator=(deque&& __x) operator=(deque&& __x)
{ {
// NB: DR 675. if (this != &__x)
this->clear(); {
this->swap(__x); // NB: DR 675.
this->clear();
this->swap(__x);
}
return *this; return *this;
} }
......
...@@ -102,9 +102,12 @@ namespace __profile ...@@ -102,9 +102,12 @@ namespace __profile
list& list&
operator=(list&& __x) operator=(list&& __x)
{ {
// NB: DR 675. if (this != &__x)
this->clear(); {
this->swap(__x); // NB: DR 675.
this->clear();
this->swap(__x);
}
return *this; return *this;
} }
......
...@@ -121,9 +121,12 @@ namespace __profile ...@@ -121,9 +121,12 @@ namespace __profile
map& map&
operator=(map&& __x) operator=(map&& __x)
{ {
// NB: DR 675. if (this != &__x)
this->clear(); {
this->swap(__x); // NB: DR 675.
this->clear();
this->swap(__x);
}
return *this; return *this;
} }
......
// Profiling multimap implementation -*- C++ -*- // Profiling multimap implementation -*- C++ -*-
// Copyright (C) 2009 Free Software Foundation, Inc. // Copyright (C) 2009, 2010 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -106,9 +106,12 @@ namespace __profile ...@@ -106,9 +106,12 @@ namespace __profile
multimap& multimap&
operator=(multimap&& __x) operator=(multimap&& __x)
{ {
// NB: DR 675. if (this != &__x)
this->clear(); {
this->swap(__x); // NB: DR 675.
this->clear();
this->swap(__x);
}
return *this; return *this;
} }
......
...@@ -104,9 +104,12 @@ namespace __profile ...@@ -104,9 +104,12 @@ namespace __profile
multiset& multiset&
operator=(multiset&& __x) operator=(multiset&& __x)
{ {
// NB: DR 675. if (this != &__x)
this->clear(); {
this->swap(__x); // NB: DR 675.
this->clear();
this->swap(__x);
}
return *this; return *this;
} }
......
...@@ -104,9 +104,12 @@ namespace __profile ...@@ -104,9 +104,12 @@ namespace __profile
set& set&
operator=(set&& __x) operator=(set&& __x)
{ {
// NB: DR 675. if (this != &__x)
this->clear(); {
this->swap(__x); // NB: DR 675.
this->clear();
this->swap(__x);
}
return *this; return *this;
} }
......
...@@ -130,9 +130,12 @@ namespace __profile ...@@ -130,9 +130,12 @@ namespace __profile
unordered_map& unordered_map&
operator=(unordered_map&& __x) operator=(unordered_map&& __x)
{ {
// NB: DR 675. if (this != &__x)
this->clear(); {
this->swap(__x); // NB: DR 675.
this->clear();
this->swap(__x);
}
return *this; return *this;
} }
...@@ -355,9 +358,12 @@ namespace __profile ...@@ -355,9 +358,12 @@ namespace __profile
unordered_multimap& unordered_multimap&
operator=(unordered_multimap&& __x) operator=(unordered_multimap&& __x)
{ {
// NB: DR 675. if (this != &__x)
this->clear(); {
this->swap(__x); // NB: DR 675.
this->clear();
this->swap(__x);
}
return *this; return *this;
} }
......
...@@ -129,9 +129,12 @@ namespace __profile ...@@ -129,9 +129,12 @@ namespace __profile
unordered_set& unordered_set&
operator=(unordered_set&& __x) operator=(unordered_set&& __x)
{ {
// NB: DR 675. if (this != &__x)
this->clear(); {
this->swap(__x); // NB: DR 675.
this->clear();
this->swap(__x);
}
return *this; return *this;
} }
...@@ -343,9 +346,12 @@ namespace __profile ...@@ -343,9 +346,12 @@ namespace __profile
unordered_multiset& unordered_multiset&
operator=(unordered_multiset&& __x) operator=(unordered_multiset&& __x)
{ {
// NB: DR 675. if (this != &__x)
this->clear(); {
this->swap(__x); // NB: DR 675.
this->clear();
this->swap(__x);
}
return *this; return *this;
} }
......
...@@ -140,9 +140,12 @@ namespace __profile ...@@ -140,9 +140,12 @@ namespace __profile
vector& vector&
operator=(vector&& __x) operator=(vector&& __x)
{ {
// NB: DR 675. if (this != &__x)
this->clear(); {
this->swap(__x); // NB: DR 675.
this->clear();
this->swap(__x);
}
return *this; return *this;
} }
......
...@@ -229,9 +229,12 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 ...@@ -229,9 +229,12 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
unordered_map& unordered_map&
operator=(unordered_map&& __x) operator=(unordered_map&& __x)
{ {
// NB: DR 675. if (this != &__x)
this->clear(); {
this->swap(__x); // NB: DR 675.
this->clear();
this->swap(__x);
}
return *this; return *this;
} }
...@@ -312,9 +315,12 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 ...@@ -312,9 +315,12 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
unordered_multimap& unordered_multimap&
operator=(unordered_multimap&& __x) operator=(unordered_multimap&& __x)
{ {
// NB: DR 675. if (this != &__x)
this->clear(); {
this->swap(__x); // NB: DR 675.
this->clear();
this->swap(__x);
}
return *this; return *this;
} }
......
// TR1 unordered_set -*- C++ -*- // TR1 unordered_set -*- C++ -*-
// Copyright (C) 2007, 2009 Free Software Foundation, Inc. // Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -222,9 +222,12 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 ...@@ -222,9 +222,12 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
unordered_set& unordered_set&
operator=(unordered_set&& __x) operator=(unordered_set&& __x)
{ {
// NB: DR 675. if (this != &__x)
this->clear(); {
this->swap(__x); // NB: DR 675.
this->clear();
this->swap(__x);
}
return *this; return *this;
} }
...@@ -302,9 +305,12 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 ...@@ -302,9 +305,12 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
unordered_multiset& unordered_multiset&
operator=(unordered_multiset&& __x) operator=(unordered_multiset&& __x)
{ {
// NB: DR 675. if (this != &__x)
this->clear(); {
this->swap(__x); // NB: DR 675.
this->clear();
this->swap(__x);
}
return *this; return *this;
} }
......
// { dg-do compile }
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
// Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc.
...@@ -19,37 +18,25 @@ ...@@ -19,37 +18,25 @@
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
#include <deque> // NOTE: This makes use of the fact that we know how moveable
#include <iterator> // is implemented on deque (via swap). If the implementation changed
#include <testsuite_iterators.h> // this test may begin to fail.
#include <testsuite_rvalref.h>
using namespace __gnu_test;
typedef std::deque<rvalstruct> test_type;
// Empty constructor doesn't require a copy constructor
void
test01()
{ test_type d; }
// Constructing from a range that returns rvalue references doesn't
// require a copy constructor.
void
test02(rvalstruct* begin, rvalstruct* end)
{
test_type d(std::make_move_iterator(begin), std::make_move_iterator(end));
}
// Constructing from a input iterator range that returns rvalue #include <deque>
// references doesn't require a copy constructor either. #include <utility>
void #include <testsuite_hooks.h>
test03(input_iterator_wrapper<rvalstruct> begin,
input_iterator_wrapper<rvalstruct> end) int main()
{ {
test_type d(std::make_move_iterator(begin), std::make_move_iterator(end)); bool test __attribute__((unused)) = true;
std::deque<int> a,b;
a.push_back(1);
b = std::move(a);
VERIFY( b.size() == 1 && b[0] == 1 && a.size() == 0 );
std::deque<int> c(std::move(b));
VERIFY( c.size() == 1 && c[0] == 1 );
VERIFY( b.size() == 0 );
return 0;
} }
// Neither does destroying one.
void
test04(test_type* d)
{ delete d; }
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// Copyright (C) 2005, 2007, 2009 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <deque>
#include <iterator>
#include <testsuite_iterators.h>
#include <testsuite_rvalref.h>
using namespace __gnu_test;
typedef std::deque<rvalstruct> test_type;
// Empty constructor doesn't require a copy constructor
void
test01()
{ test_type d; }
// Constructing from a range that returns rvalue references doesn't
// require a copy constructor.
void
test02(rvalstruct* begin, rvalstruct* end)
{
test_type d(std::make_move_iterator(begin), std::make_move_iterator(end));
}
// Constructing from a input iterator range that returns rvalue
// references doesn't require a copy constructor either.
void
test03(input_iterator_wrapper<rvalstruct> begin,
input_iterator_wrapper<rvalstruct> end)
{
test_type d(std::make_move_iterator(begin), std::make_move_iterator(end));
}
// Neither does destroying one.
void
test04(test_type* d)
{ delete d; }
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
// Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc. // 2010-01-08 Paolo Carlini <paolo.carlini@oracle.com>
// Copyright (C) 2010 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -17,26 +19,22 @@ ...@@ -17,26 +19,22 @@
// with this library; see the file COPYING3. If not see // with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// NOTE: This makes use of the fact that we know how moveable
// is implemented on deque (via swap). If the implementation changed
// this test may begin to fail.
#include <deque> #include <deque>
#include <utility>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
int main() void test01()
{ {
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::deque<int> a,b; std::deque<int> d0(10, 1);
a.push_back(1); const std::deque<int> d1(d0);
b = std::move(a); d0 = std::move(d0);
VERIFY( b.size() == 1 && b[0] == 1 && a.size() == 0 ); VERIFY( d0.size() == 10 );
VERIFY( d0 == d1 );
}
std::deque<int> c(std::move(b)); int main()
VERIFY( c.size() == 1 && c[0] == 1 ); {
VERIFY( b.size() == 0 ); test01();
return 0; return 0;
} }
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// { dg-do compile } // { dg-do compile }
// { dg-error "no matching" "" { target *-*-* } 1575 } // { dg-error "no matching" "" { target *-*-* } 1578 }
// { dg-excess-errors "" } // { dg-excess-errors "" }
#include <deque> #include <deque>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// { dg-do compile } // { dg-do compile }
// { dg-error "no matching" "" { target *-*-* } 1514 } // { dg-error "no matching" "" { target *-*-* } 1517 }
// { dg-excess-errors "" } // { dg-excess-errors "" }
#include <deque> #include <deque>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// { dg-do compile } // { dg-do compile }
// { dg-error "no matching" "" { target *-*-* } 1514 } // { dg-error "no matching" "" { target *-*-* } 1517 }
// { dg-excess-errors "" } // { dg-excess-errors "" }
#include <deque> #include <deque>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// { dg-do compile } // { dg-do compile }
// { dg-error "no matching" "" { target *-*-* } 1659 } // { dg-error "no matching" "" { target *-*-* } 1662 }
// { dg-excess-errors "" } // { dg-excess-errors "" }
#include <deque> #include <deque>
......
// { dg-options "-std=gnu++0x" }
// 2010-01-08 Paolo Carlini <paolo.carlini@oracle.com>
// Copyright (C) 2010 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <forward_list>
#include <testsuite_hooks.h>
void test01()
{
bool test __attribute__((unused)) = true;
std::forward_list<int> fl0(10, 1);
const std::forward_list<int> fl1(fl0);
fl0 = std::move(fl0);
// VERIFY( fl0.size() == 10 );
VERIFY( fl0 == fl1 );
}
int main()
{
test01();
return 0;
}
// { dg-options "-std=gnu++0x" }
// 2010-01-08 Paolo Carlini <paolo.carlini@oracle.com>
// Copyright (C) 2010 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <list>
#include <testsuite_hooks.h>
void test01()
{
bool test __attribute__((unused)) = true;
std::list<int> l0(10, 1);
const std::list<int> l1(l0);
l0 = std::move(l0);
VERIFY( l0.size() == 10 );
VERIFY( l0 == l1 );
}
int main()
{
test01();
return 0;
}
// 2007-04-27 Paolo Carlini <pcarlini@suse.de> // 2007-04-27 Paolo Carlini <pcarlini@suse.de>
// Copyright (C) 2007, 2008, 2009 Free Software Foundation // Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// { dg-do compile } // { dg-do compile }
// { dg-error "no matching" "" { target *-*-* } 1409 } // { dg-error "no matching" "" { target *-*-* } 1412 }
// { dg-excess-errors "" } // { dg-excess-errors "" }
#include <list> #include <list>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// { dg-do compile } // { dg-do compile }
// { dg-error "no matching" "" { target *-*-* } 1378 } // { dg-error "no matching" "" { target *-*-* } 1381 }
// { dg-excess-errors "" } // { dg-excess-errors "" }
#include <list> #include <list>
......
// 2007-04-27 Paolo Carlini <pcarlini@suse.de> // 2007-04-27 Paolo Carlini <pcarlini@suse.de>
// Copyright (C) 2007, 2008, 2009 Free Software Foundation // Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// { dg-do compile } // { dg-do compile }
// { dg-error "no matching" "" { target *-*-* } 1378 } // { dg-error "no matching" "" { target *-*-* } 1381 }
// { dg-excess-errors "" } // { dg-excess-errors "" }
#include <list> #include <list>
......
// 2007-04-27 Paolo Carlini <pcarlini@suse.de> // 2007-04-27 Paolo Carlini <pcarlini@suse.de>
// Copyright (C) 2007, 2008, 2009 Free Software Foundation // Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// { dg-do compile } // { dg-do compile }
// { dg-error "no matching" "" { target *-*-* } 1378 } // { dg-error "no matching" "" { target *-*-* } 1381 }
// { dg-excess-errors "" } // { dg-excess-errors "" }
#include <list> #include <list>
......
// { dg-options "-std=gnu++0x" }
// 2010-01-08 Paolo Carlini <paolo.carlini@oracle.com>
// Copyright (C) 2010 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <map>
#include <testsuite_hooks.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef std::map<int, int> map_type;
typedef map_type::value_type value_type;
map_type m0{ value_type(1, 1), value_type(2, 2), value_type(3, 3) };
const map_type m1(m0);
m0 = std::move(m0);
VERIFY( m0.size() == 3 );
VERIFY( m0 == m1 );
}
int main()
{
test01();
return 0;
}
// { dg-options "-std=gnu++0x" }
// 2010-01-08 Paolo Carlini <paolo.carlini@oracle.com>
// Copyright (C) 2010 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <map>
#include <testsuite_hooks.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef std::multimap<int, int> mmap_type;
typedef mmap_type::value_type value_type;
mmap_type mm0{ value_type(1, 1), value_type(2, 2), value_type(3, 3) };
const mmap_type mm1(mm0);
mm0 = std::move(mm0);
VERIFY( mm0.size() == 3 );
VERIFY( mm0 == mm1 );
}
int main()
{
test01();
return 0;
}
// { dg-options "-std=gnu++0x" }
// 2010-01-08 Paolo Carlini <paolo.carlini@oracle.com>
// Copyright (C) 2010 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <set>
#include <testsuite_hooks.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef std::multiset<int> mset_type;
mset_type ms0{ 1, 2, 3 };
const mset_type ms1(ms0);
ms0 = std::move(ms0);
VERIFY( ms0.size() == 3 );
VERIFY( ms0 == ms1 );
}
int main()
{
test01();
return 0;
}
// { dg-options "-std=gnu++0x" }
// 2010-01-08 Paolo Carlini <paolo.carlini@oracle.com>
// Copyright (C) 2010 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <set>
#include <testsuite_hooks.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef std::set<int> set_type;
set_type s0{ 1, 2, 3 };
const set_type s1(s0);
s0 = std::move(s0);
VERIFY( s0.size() == 3 );
VERIFY( s0 == s1 );
}
int main()
{
test01();
return 0;
}
// { dg-options "-std=gnu++0x" }
// 2010-01-08 Paolo Carlini <paolo.carlini@oracle.com>
// Copyright (C) 2010 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <unordered_map>
#include <testsuite_hooks.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef std::unordered_map<int, int> umap_type;
typedef umap_type::value_type value_type;
umap_type um0{ value_type(1, 1), value_type(2, 2), value_type(3, 3) };
const umap_type um1(um0);
um0 = std::move(um0);
VERIFY( um0.size() == 3 );
// VERIFY( um0 == um1 );
}
int main()
{
test01();
return 0;
}
// { dg-options "-std=gnu++0x" }
// 2010-01-08 Paolo Carlini <paolo.carlini@oracle.com>
// Copyright (C) 2010 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <unordered_map>
#include <testsuite_hooks.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef std::unordered_multimap<int, int> ummap_type;
typedef ummap_type::value_type value_type;
ummap_type umm0{ value_type(1, 1), value_type(2, 2), value_type(3, 3) };
const ummap_type umm1(umm0);
umm0 = std::move(umm0);
VERIFY( umm0.size() == 3 );
// VERIFY( umm0 == umm1 );
}
int main()
{
test01();
return 0;
}
// { dg-options "-std=gnu++0x" }
// 2010-01-08 Paolo Carlini <paolo.carlini@oracle.com>
// Copyright (C) 2010 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <unordered_set>
#include <testsuite_hooks.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef std::unordered_multiset<int> umset_type;
umset_type ums0{ 1, 2, 3 };
const umset_type ums1(ums0);
ums0 = std::move(ums0);
VERIFY( ums0.size() == 3 );
// VERIFY( ums0 == ums1 );
}
int main()
{
test01();
return 0;
}
// { dg-options "-std=gnu++0x" }
// 2010-01-08 Paolo Carlini <paolo.carlini@oracle.com>
// Copyright (C) 2010 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <unordered_set>
#include <testsuite_hooks.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef std::unordered_set<int> uset_type;
uset_type us0{ 1, 2, 3 };
const uset_type us1(us0);
us0 = std::move(us0);
VERIFY( us0.size() == 3 );
// VERIFY( us0 == us1 );
}
int main()
{
test01();
return 0;
}
// { dg-do compile }
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
// Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc.
...@@ -19,37 +18,45 @@ ...@@ -19,37 +18,45 @@
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// NOTE: This makes use of the fact that we know how moveable
// is implemented on vector (via swap). If the implementation changed
// this test may begin to fail.
#include <vector> #include <vector>
#include <iterator> #include <utility>
#include <testsuite_iterators.h> #include <testsuite_hooks.h>
#include <testsuite_rvalref.h>
void test01()
using namespace __gnu_test; {
typedef std::vector<rvalstruct> test_type; bool test __attribute__((unused)) = true;
// Empty constructor doesn't require a copy constructor std::vector<int> a,b;
void a.push_back(1);
test01() b = std::move(a);
{ test_type d; } VERIFY( b.size() == 1 && b[0] == 1 && a.size() == 0 );
// Constructing from a range that returns rvalue references doesn't std::vector<int> c(std::move(b));
// require a copy constructor. VERIFY( c.size() == 1 && c[0] == 1 );
void VERIFY( b.size() == 0 );
test02(rvalstruct* begin, rvalstruct* end)
{
test_type d(std::make_move_iterator(begin), std::make_move_iterator(end));
} }
// Constructing from a input iterator range that returns rvalue void test02()
// references doesn't require a copy constructor either. {
void bool test __attribute__((unused)) = true;
test03(input_iterator_wrapper<rvalstruct> begin,
input_iterator_wrapper<rvalstruct> end) std::vector<bool> a,b;
{ a.push_back(1);
test_type d(std::make_move_iterator(begin), std::make_move_iterator(end)); b = std::move(a);
VERIFY( b.size() == 1 && b[0] == 1 && a.size() == 0 );
std::vector<bool> c(std::move(b));
VERIFY( c.size() == 1 && c[0] == 1 );
VERIFY( b.size() == 0 );
} }
// Neither does destroying one. int main(void)
void {
test04(test_type* d) test01();
{ delete d; } test02();
return 0;
}
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// Copyright (C) 2005, 2007, 2009 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <vector>
#include <iterator>
#include <testsuite_iterators.h>
#include <testsuite_rvalref.h>
using namespace __gnu_test;
typedef std::vector<rvalstruct> test_type;
// Empty constructor doesn't require a copy constructor
void
test01()
{ test_type d; }
// Constructing from a range that returns rvalue references doesn't
// require a copy constructor.
void
test02(rvalstruct* begin, rvalstruct* end)
{
test_type d(std::make_move_iterator(begin), std::make_move_iterator(end));
}
// Constructing from a input iterator range that returns rvalue
// references doesn't require a copy constructor either.
void
test03(input_iterator_wrapper<rvalstruct> begin,
input_iterator_wrapper<rvalstruct> end)
{
test_type d(std::make_move_iterator(begin), std::make_move_iterator(end));
}
// Neither does destroying one.
void
test04(test_type* d)
{ delete d; }
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
// Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc. // 2010-01-08 Paolo Carlini <paolo.carlini@oracle.com>
// Copyright (C) 2010 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -17,46 +19,22 @@ ...@@ -17,46 +19,22 @@
// with this library; see the file COPYING3. If not see // with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// NOTE: This makes use of the fact that we know how moveable
// is implemented on vector (via swap). If the implementation changed
// this test may begin to fail.
#include <vector> #include <vector>
#include <utility>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
void test01() void test01()
{ {
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::vector<int> a,b; std::vector<int> v0(10, 1);
a.push_back(1); const std::vector<int> v1(v0);
b = std::move(a); v0 = std::move(v0);
VERIFY( b.size() == 1 && b[0] == 1 && a.size() == 0 ); VERIFY( v0.size() == 10 );
VERIFY( v0 == v1 );
std::vector<int> c(std::move(b));
VERIFY( c.size() == 1 && c[0] == 1 );
VERIFY( b.size() == 0 );
}
void test02()
{
bool test __attribute__((unused)) = true;
std::vector<bool> a,b;
a.push_back(1);
b = std::move(a);
VERIFY( b.size() == 1 && b[0] == 1 && a.size() == 0 );
std::vector<bool> c(std::move(b));
VERIFY( c.size() == 1 && c[0] == 1 );
VERIFY( b.size() == 0 );
} }
int main(void) int main()
{ {
test01(); test01();
test02();
return 0; return 0;
} }
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// { dg-do compile } // { dg-do compile }
// { dg-error "no matching" "" { target *-*-* } 1054 } // { dg-error "no matching" "" { target *-*-* } 1057 }
// { dg-excess-errors "" } // { dg-excess-errors "" }
#include <vector> #include <vector>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// { dg-do compile } // { dg-do compile }
// { dg-error "no matching" "" { target *-*-* } 994 } // { dg-error "no matching" "" { target *-*-* } 997 }
// { dg-excess-errors "" } // { dg-excess-errors "" }
#include <vector> #include <vector>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// { dg-do compile } // { dg-do compile }
// { dg-error "no matching" "" { target *-*-* } 994 } // { dg-error "no matching" "" { target *-*-* } 997 }
// { dg-excess-errors "" } // { dg-excess-errors "" }
#include <vector> #include <vector>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// { dg-do compile } // { dg-do compile }
// { dg-error "no matching" "" { target *-*-* } 1095 } // { dg-error "no matching" "" { target *-*-* } 1098 }
// { dg-excess-errors "" } // { dg-excess-errors "" }
#include <vector> #include <vector>
......
// { dg-options "-std=gnu++0x" }
// { dg-require-string-conversions "" }
// 2010-01-08 Paolo Carlini <paolo.carlini@oracle.com>
// Copyright (C) 2010 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <ext/vstring.h>
#include <testsuite_hooks.h>
void test01()
{
bool test __attribute__((unused)) = true;
__gnu_cxx::__vstring vs0(10, 'a');
const __gnu_cxx::__vstring vs1(vs0);
vs0 = std::move(vs0);
VERIFY( vs0.size() == 10 );
VERIFY( vs0 == vs1 );
}
int main()
{
test01();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment