Patchwork [v3] Couple of small clean-ups (to forward_list::swap, in particular)

login
register
mail settings
Submitter Paolo Carlini
Date Oct. 25, 2010, 10:48 a.m.
Message ID <4CC5607E.3070904@oracle.com>
Download mbox | patch
Permalink /patch/69086/
State New
Headers show

Comments

Paolo Carlini - Oct. 25, 2010, 10:48 a.m.
Hi,

tested x86_64-linux, committed.

Paolo.

///////////////////
2010-10-25  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/bits/hashtable.h (_Hashtable<>:_M_get_Value_allocator):
	Remove, unused.
2010-10-25  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/bits/forward_list.h (_Fwd_list_node_base::swap): Remove.
	(_Fwd_list_base<>::_Fwd_list_base(_Fwd_list_base&&),
	_Fwd_list_base<>::_Fwd_list_base(_Fwd_list_base&&, const _Alloc&)):
	Don't use swap.
	(forward_list<>::swap): Just use std::swap.

	* include/bits/forward_list.h (_Fwd_list_base<>::_Fwd_list_base(),
	_Fwd_list_base(const _Alloc&)): Don't zero again _M_next.

	* testsuite/23_containers/forward_list/requirements/dr438/
	assign_neg.cc: Adjust dg-error line number.
	* testsuite/23_containers/forward_list/requirements/dr438/
	insert_neg.cc: Likewise.
	* testsuite/23_containers/forward_list/requirements/dr438/
	constructor_1_neg.cc: Likewise.
	* testsuite/23_containers/forward_list/requirements/dr438/
	constructor_2_neg.cc: Likewise.

Index: include/bits/forward_list.h
===================================================================
--- include/bits/forward_list.h	(revision 165910)
+++ include/bits/forward_list.h	(working copy)
@@ -47,10 +47,6 @@
 
     _Fwd_list_node_base* _M_next;
 
-    static void
-    swap(_Fwd_list_node_base& __x, _Fwd_list_node_base& __y)
-    { std::swap(__x._M_next, __y._M_next); }
-
     _Fwd_list_node_base*
     _M_transfer_after(_Fwd_list_node_base* __begin)
     {
@@ -309,24 +305,26 @@
       { return *static_cast<const _Node_alloc_type*>(&this->_M_impl); }
 
       _Fwd_list_base()
-      : _M_impl()
-      { this->_M_impl._M_head._M_next = 0; }
+      : _M_impl() { }
 
       _Fwd_list_base(const _Alloc& __a)
-      : _M_impl(__a)
-      { this->_M_impl._M_head._M_next = 0; }
+      : _M_impl(__a) { }
 
       _Fwd_list_base(const _Fwd_list_base& __lst, const _Alloc& __a);
 
       _Fwd_list_base(_Fwd_list_base&& __lst, const _Alloc& __a)
       : _M_impl(__a)
-      { _Fwd_list_node_base::swap(this->_M_impl._M_head,
-				  __lst._M_impl._M_head); }
+      {
+	this->_M_impl._M_head._M_next = __lst._M_impl._M_head._M_next;
+	__lst._M_impl._M_head._M_next = 0;
+      }
 
       _Fwd_list_base(_Fwd_list_base&& __lst)
       : _M_impl(__lst._M_get_Node_allocator())
-      { _Fwd_list_node_base::swap(this->_M_impl._M_head,
-				  __lst._M_impl._M_head); }
+      {
+	this->_M_impl._M_head._M_next = __lst._M_impl._M_head._M_next;
+	__lst._M_impl._M_head._M_next = 0;
+      }
 
       ~_Fwd_list_base()
       { _M_erase_after(&_M_impl._M_head, 0); }
@@ -979,7 +977,8 @@
        */
       void
       swap(forward_list& __list)
-      { _Node_base::swap(this->_M_impl._M_head, __list._M_impl._M_head); }
+      { std::swap(this->_M_impl._M_head._M_next,
+		  __list._M_impl._M_head._M_next); }
 
       /**
        *  @brief Resizes the %forward_list to the specified number of
Index: testsuite/23_containers/forward_list/requirements/dr438/assign_neg.cc
===================================================================
--- testsuite/23_containers/forward_list/requirements/dr438/assign_neg.cc	(revision 165910)
+++ testsuite/23_containers/forward_list/requirements/dr438/assign_neg.cc	(working copy)
@@ -1,6 +1,6 @@
 // { dg-do compile }
 // { dg-options "-std=gnu++0x" }
-// { dg-error "no matching" "" { target *-*-* } 1204 }
+// { dg-error "no matching" "" { target *-*-* } 1203 }
 // { dg-excess-errors "" }
 
 // Copyright (C) 2009, 2010 Free Software Foundation
Index: testsuite/23_containers/forward_list/requirements/dr438/insert_neg.cc
===================================================================
--- testsuite/23_containers/forward_list/requirements/dr438/insert_neg.cc	(revision 165910)
+++ testsuite/23_containers/forward_list/requirements/dr438/insert_neg.cc	(working copy)
@@ -1,6 +1,6 @@
 // { dg-do compile }
 // { dg-options "-std=gnu++0x" }
-// { dg-error "no matching" "" { target *-*-* } 1204 }
+// { dg-error "no matching" "" { target *-*-* } 1203 }
 // { dg-excess-errors "" }
 
 // Copyright (C) 2009, 2010 Free Software Foundation
Index: testsuite/23_containers/forward_list/requirements/dr438/constructor_1_neg.cc
===================================================================
--- testsuite/23_containers/forward_list/requirements/dr438/constructor_1_neg.cc	(revision 165910)
+++ testsuite/23_containers/forward_list/requirements/dr438/constructor_1_neg.cc	(working copy)
@@ -1,6 +1,6 @@
 // { dg-do compile }
 // { dg-options "-std=gnu++0x" }
-// { dg-error "no matching" "" { target *-*-* } 1204 }
+// { dg-error "no matching" "" { target *-*-* } 1203 }
 // { dg-excess-errors "" }
 
 // Copyright (C) 2009, 2010 Free Software Foundation
Index: testsuite/23_containers/forward_list/requirements/dr438/constructor_2_neg.cc
===================================================================
--- testsuite/23_containers/forward_list/requirements/dr438/constructor_2_neg.cc	(revision 165910)
+++ testsuite/23_containers/forward_list/requirements/dr438/constructor_2_neg.cc	(working copy)
@@ -1,6 +1,6 @@
 // { dg-do compile }
 // { dg-options "-std=gnu++0x" }
-// { dg-error "no matching" "" { target *-*-* } 1204 }
+// { dg-error "no matching" "" { target *-*-* } 1203 }
 // { dg-excess-errors "" }
 
 // Copyright (C) 2009, 2010 Free Software Foundation

Patch

Index: include/bits/hashtable.h
===================================================================
--- include/bits/hashtable.h	(revision 165910)
+++ include/bits/hashtable.h	(working copy)
@@ -271,10 +271,6 @@ 
       get_allocator() const
       { return allocator_type(_M_node_allocator); }
 
-      _Value_allocator_type
-      _M_get_Value_allocator() const
-      { return _Value_allocator_type(_M_node_allocator); }
-
       size_type
       max_size() const
       { return _M_node_allocator.max_size(); }