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]

Re: Implementation of forward_list (and compressed_pair)


Paolo Carlini wrote:
> Hi Ion,
>   
>> And it will surely work for also for stl_tree.h changing just
>> _Rb_tree_node and in _M_create_node. Of course, same for unordered
>> containers.
>>     
> Excellent. I'll take care of that.
>   
And this is what I committed to mainline for std::list. Tested x86_64-linux.

Paolo.

//////////////////////
2008-10-14  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/bits/stl_list.h (_List_node<>::_List_node<>(_Args&&...)):
	Add in C++0x mode.
	(list<>::_M_create_node<>(_Args&&...)): Use _M_get_Node_allocator.
	(list<>::_M_erase(iterator): Likewise, in C++0x mode.
	* include/bits/list.tcc (_List_base<>::_M_clear): Likewise.
	* testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
	Adjust dg-error line number.
	* 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.
Index: include/bits/stl_list.h
===================================================================
*** include/bits/stl_list.h	(revision 141110)
--- include/bits/stl_list.h	(working copy)
*************** _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GL
*** 101,106 ****
--- 101,112 ----
      {
        ///< User's data.
        _Tp _M_data;
+ 
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
+       template<typename... _Args>
+         _List_node(_Args&&... __args)
+ 	: _List_node_base(), _M_data(std::forward<_Args>(__args)...) { }
+ #endif
      };
  
    /**
*************** _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GL
*** 478,485 ****
  	  _Node* __p = this->_M_get_node();
  	  try
  	    {
! 	      _M_get_Tp_allocator().construct(&__p->_M_data,
! 					      std::forward<_Args>(__args)...);
  	    }
  	  catch(...)
  	    {
--- 484,491 ----
  	  _Node* __p = this->_M_get_node();
  	  try
  	    {
! 	      _M_get_Node_allocator().construct(__p,
! 						std::forward<_Args>(__args)...);
  	    }
  	  catch(...)
  	    {
*************** _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GL
*** 1423,1429 ****
        {
          __position._M_node->unhook();
          _Node* __n = static_cast<_Node*>(__position._M_node);
!         _M_get_Tp_allocator().destroy(&__n->_M_data);
          _M_put_node(__n);
        }
  
--- 1429,1439 ----
        {
          __position._M_node->unhook();
          _Node* __n = static_cast<_Node*>(__position._M_node);
! #ifdef __GXX_EXPERIMENTAL_CXX0X__
!         _M_get_Node_allocator().destroy(__n);
! #else
! 	_M_get_Tp_allocator().destroy(&__n->_M_data);
! #endif
          _M_put_node(__n);
        }
  
Index: include/bits/list.tcc
===================================================================
*** include/bits/list.tcc	(revision 141104)
--- include/bits/list.tcc	(working copy)
***************
*** 1,6 ****
  // List implementation (out of line) -*- C++ -*-
  
! // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
  // Free Software Foundation, Inc.
  //
  // This file is part of the GNU ISO C++ Library.  This library is free
--- 1,6 ----
  // List implementation (out of line) -*- C++ -*-
  
! // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
  // Free Software Foundation, Inc.
  //
  // This file is part of the GNU ISO C++ Library.  This library is free
*************** _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GL
*** 75,81 ****
--- 75,85 ----
  	{
  	  _Node* __tmp = __cur;
  	  __cur = static_cast<_Node*>(__cur->_M_next);
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
+ 	  _M_get_Node_allocator().destroy(__tmp);
+ #else
  	  _M_get_Tp_allocator().destroy(&__tmp->_M_data);
+ #endif
  	  _M_put_node(__tmp);
  	}
      }
Index: testsuite/23_containers/list/requirements/dr438/assign_neg.cc
===================================================================
*** testsuite/23_containers/list/requirements/dr438/assign_neg.cc	(revision 141104)
--- testsuite/23_containers/list/requirements/dr438/assign_neg.cc	(working copy)
***************
*** 19,25 ****
  // USA.
  
  // { dg-do compile }
! // { dg-error "no matching" "" { target *-*-* } 1383 }
  // { dg-excess-errors "" }
  
  #include <list>
--- 19,25 ----
  // USA.
  
  // { dg-do compile }
! // { dg-error "no matching" "" { target *-*-* } 1389 }
  // { dg-excess-errors "" }
  
  #include <list>
Index: testsuite/23_containers/list/requirements/dr438/insert_neg.cc
===================================================================
*** testsuite/23_containers/list/requirements/dr438/insert_neg.cc	(revision 141104)
--- testsuite/23_containers/list/requirements/dr438/insert_neg.cc	(working copy)
***************
*** 19,25 ****
  // USA.
  
  // { dg-do compile }
! // { dg-error "no matching" "" { target *-*-* } 1352 }
  // { dg-excess-errors "" }
  
  #include <list>
--- 19,25 ----
  // USA.
  
  // { dg-do compile }
! // { dg-error "no matching" "" { target *-*-* } 1358 }
  // { dg-excess-errors "" }
  
  #include <list>
Index: testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc
===================================================================
*** testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc	(revision 141104)
--- testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc	(working copy)
***************
*** 19,25 ****
  // USA.
  
  // { dg-do compile }
! // { dg-error "no matching" "" { target *-*-* } 1352 }
  // { dg-excess-errors "" }
  
  #include <list>
--- 19,25 ----
  // USA.
  
  // { dg-do compile }
! // { dg-error "no matching" "" { target *-*-* } 1358 }
  // { dg-excess-errors "" }
  
  #include <list>
Index: testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc
===================================================================
*** testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc	(revision 141104)
--- testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc	(working copy)
***************
*** 19,25 ****
  // USA.
  
  // { dg-do compile }
! // { dg-error "no matching" "" { target *-*-* } 1352 }
  // { dg-excess-errors "" }
  
  #include <list>
--- 19,25 ----
  // USA.
  
  // { dg-do compile }
! // { dg-error "no matching" "" { target *-*-* } 1358 }
  // { dg-excess-errors "" }
  
  #include <list>

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