This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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] In C++0x mode use only Node_allocator in _Rb_tree too


Hi,

similarly to the recent changes to list. Tested x86_64-linux, committed
to mainline.

Paolo.

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

	* include/bits/stl_tree.h (_Rb_tree_node<>::_Rb_tree_node<>
	(_Args&&...)): Add in C++0x mode.
	(_Rb_tree<>::_M_create_node<>(_Args&&...)): Add in C++0x mode,
	use _M_get_Node_allocator.
	(_Rb_tree<>::_M_destroy_node(_Link_type): Use _M_get_Node_allocator
	in C++0x mode.
	* testsuite/23_containers/set/operators/1_neg.cc: Adjust dg-error
	line numbers.
	* testsuite/23_containers/map/operators/1_neg.cc: Likewise.
Index: include/bits/stl_tree.h
===================================================================
*** include/bits/stl_tree.h	(revision 141220)
--- include/bits/stl_tree.h	(working copy)
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 133,138 ****
--- 133,145 ----
      {
        typedef _Rb_tree_node<_Val>* _Link_type;
        _Val _M_value_field;
+ 
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
+       template<typename... _Args>
+         _Rb_tree_node(_Args&&... __args)
+ 	: _Rb_tree_node_base(),
+ 	  _M_value_field(std::forward<_Args>(__args)...) { }
+ #endif
      };
  
    _Rb_tree_node_base*
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 360,365 ****
--- 367,373 ----
        _M_put_node(_Link_type __p)
        { _M_impl._Node_allocator::deallocate(__p, 1); }
  
+ #ifndef __GXX_EXPERIMENTAL_CXX0X__
        _Link_type
        _M_create_node(const value_type& __x)
        {
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 374,379 ****
--- 382,420 ----
  	return __tmp;
        }
  
+       void
+       _M_destroy_node(_Link_type __p)
+       {
+ 	get_allocator().destroy(&__p->_M_value_field);
+ 	_M_put_node(__p);
+       }
+ #else
+       template<typename... _Args>
+         _Link_type
+         _M_create_node(_Args&&... __args)
+ 	{
+ 	  _Link_type __tmp = _M_get_node();
+ 	  try
+ 	    {
+ 	      _M_get_Node_allocator().construct(__tmp,
+ 					     std::forward<_Args>(__args)...);
+ 	    }
+ 	  catch(...)
+ 	    {
+ 	      _M_put_node(__tmp);
+ 	      __throw_exception_again;
+ 	    }
+ 	  return __tmp;
+ 	}
+ 
+       void
+       _M_destroy_node(_Link_type __p)
+       {
+ 	_M_get_Node_allocator().destroy(__p);
+ 	_M_put_node(__p);
+       }
+ #endif
+ 
        _Link_type
        _M_clone_node(_Const_Link_type __x)
        {
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 384,396 ****
  	return __tmp;
        }
  
-       void
-       _M_destroy_node(_Link_type __p)
-       {
- 	get_allocator().destroy(&__p->_M_value_field);
- 	_M_put_node(__p);
-       }
- 
      protected:
        template<typename _Key_compare, 
  	       bool _Is_pod_comparator = __is_pod(_Key_compare)>
--- 425,430 ----
Index: testsuite/23_containers/set/operators/1_neg.cc
===================================================================
*** testsuite/23_containers/set/operators/1_neg.cc	(revision 141220)
--- testsuite/23_containers/set/operators/1_neg.cc	(working copy)
***************
*** 1,6 ****
  // { dg-do compile }
  
! // Copyright (C) 2000, 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 ----
  // { dg-do compile }
  
! // Copyright (C) 2000, 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
*************** void test01()
*** 40,44 ****
    test &= itr == setByName.end(); // { dg-error "no" } 
  }
  
! // { dg-error "candidates are" "" { target *-*-* } 285 }
! // { dg-error "candidates are" "" { target *-*-* } 289 }
--- 40,44 ----
    test &= itr == setByName.end(); // { dg-error "no" } 
  }
  
! // { dg-error "candidates are" "" { target *-*-* } 292 }
! // { dg-error "candidates are" "" { target *-*-* } 296 }
Index: testsuite/23_containers/map/operators/1_neg.cc
===================================================================
*** testsuite/23_containers/map/operators/1_neg.cc	(revision 141220)
--- testsuite/23_containers/map/operators/1_neg.cc	(working copy)
***************
*** 1,6 ****
  // { dg-do compile }
  
! // Copyright (C) 2000, 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 ----
  // { dg-do compile }
  
! // Copyright (C) 2000, 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
*************** void test01()
*** 42,46 ****
    test &= itr == mapByName.end(); // { dg-error "no" } 
  }
   
! // { dg-error "candidates are" "" { target *-*-* } 210 }
! // { dg-error "candidates are" "" { target *-*-* } 214 }
--- 42,46 ----
    test &= itr == mapByName.end(); // { dg-error "no" } 
  }
   
! // { dg-error "candidates are" "" { target *-*-* } 217 }
! // { dg-error "candidates are" "" { target *-*-* } 221 }

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