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] Improve max_size of some containers


Hi,

tested x86_64-linux, committed to mainline.

Paolo.

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

	* include/bits/stl_tree.h (_Rb_tree<>::max_size): Use Node_allocator
	for improved accuracy.
	* include/bits/stl_list.h (list<>::max_size): Likewise.
	* testsuite/23_containers/multimap/capacity/29134.cc: Adjust.
	* testsuite/23_containers/set/capacity/29134.cc: Likewise.
	* testsuite/23_containers/multiset/capacity/29134.cc: Likewise.
	* testsuite/23_containers/list/capacity/29134.cc: Likewise.
	* testsuite/23_containers/map/capacity/29134.cc: Likewise.
Index: include/bits/stl_list.h
===================================================================
*** include/bits/stl_list.h	(revision 141104)
--- include/bits/stl_list.h	(working copy)
*************** _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GL
*** 807,813 ****
        /**  Returns the size() of the largest possible %list.  */
        size_type
        max_size() const
!       { return _M_get_Tp_allocator().max_size(); }
  
        /**
         *  @brief Resizes the %list to the specified number of elements.
--- 807,813 ----
        /**  Returns the size() of the largest possible %list.  */
        size_type
        max_size() const
!       { return _M_get_Node_allocator().max_size(); }
  
        /**
         *  @brief Resizes the %list to the specified number of elements.
Index: include/bits/stl_tree.h
===================================================================
*** include/bits/stl_tree.h	(revision 141104)
--- include/bits/stl_tree.h	(working copy)
***************
*** 1,6 ****
  // RB tree implementation -*- 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 ----
  // RB tree implementation -*- 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_NAMESPACE(std)
*** 643,649 ****
  
        size_type
        max_size() const
!       { return get_allocator().max_size(); }
  
        void
  #ifdef __GXX_EXPERIMENTAL_CXX0X__
--- 643,649 ----
  
        size_type
        max_size() const
!       { return _M_get_Node_allocator().max_size(); }
  
        void
  #ifdef __GXX_EXPERIMENTAL_CXX0X__
Index: testsuite/23_containers/multimap/capacity/29134.cc
===================================================================
*** testsuite/23_containers/multimap/capacity/29134.cc	(revision 141104)
--- testsuite/23_containers/multimap/capacity/29134.cc	(working copy)
***************
*** 1,4 ****
! // Copyright (C) 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
--- 1,4 ----
! // Copyright (C) 2006, 2007, 2008 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
*************** void test01()
*** 28,34 ****
  
    std::multimap<int, int> mm;
  
!   VERIFY( mm.max_size() == mm.get_allocator().max_size() );
  }
  
  int main()
--- 28,35 ----
  
    std::multimap<int, int> mm;
  
!   VERIFY( (mm.max_size() == std::allocator<std::_Rb_tree_node<
! 	                    std::pair<const int, int> > >().max_size()) );
  }
  
  int main()
Index: testsuite/23_containers/set/capacity/29134.cc
===================================================================
*** testsuite/23_containers/set/capacity/29134.cc	(revision 141104)
--- testsuite/23_containers/set/capacity/29134.cc	(working copy)
***************
*** 1,4 ****
! // Copyright (C) 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
--- 1,4 ----
! // Copyright (C) 2006, 2007, 2008 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
*************** void test01()
*** 28,34 ****
  
    std::set<int> s;
  
!   VERIFY( s.max_size() == s.get_allocator().max_size() );
  }
  
  int main()
--- 28,35 ----
  
    std::set<int> s;
  
!   VERIFY( s.max_size() ==
! 	  std::allocator<std::_Rb_tree_node<int> >().max_size() );
  }
  
  int main()
Index: testsuite/23_containers/multiset/capacity/29134.cc
===================================================================
*** testsuite/23_containers/multiset/capacity/29134.cc	(revision 141104)
--- testsuite/23_containers/multiset/capacity/29134.cc	(working copy)
***************
*** 1,4 ****
! // Copyright (C) 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
--- 1,4 ----
! // Copyright (C) 2006, 2007, 2008 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
*************** void test01()
*** 28,34 ****
  
    std::multiset<int> ms;
  
!   VERIFY( ms.max_size() == ms.get_allocator().max_size() );
  }
  
  int main()
--- 28,35 ----
  
    std::multiset<int> ms;
  
!   VERIFY( ms.max_size()
! 	  == std::allocator<std::_Rb_tree_node<int> >().max_size() );
  }
  
  int main()
Index: testsuite/23_containers/list/capacity/29134.cc
===================================================================
*** testsuite/23_containers/list/capacity/29134.cc	(revision 141104)
--- testsuite/23_containers/list/capacity/29134.cc	(working copy)
***************
*** 1,4 ****
! // Copyright (C) 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
--- 1,4 ----
! // Copyright (C) 2006, 2007, 2008 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
*************** void test01()
*** 28,34 ****
  
    std::list<int> l;
  
!   VERIFY( l.max_size() == l.get_allocator().max_size() );
  }
  
  int main()
--- 28,40 ----
  
    std::list<int> l;
  
! #ifndef _GLIBCXX_DEBUG
!   using std::_List_node;
! #else
!   using std::_GLIBCXX_STD_D::_List_node;
! #endif
! 
!   VERIFY( l.max_size() == std::allocator<_List_node<int> >().max_size() );
  }
  
  int main()
Index: testsuite/23_containers/map/capacity/29134.cc
===================================================================
*** testsuite/23_containers/map/capacity/29134.cc	(revision 141104)
--- testsuite/23_containers/map/capacity/29134.cc	(working copy)
***************
*** 1,4 ****
! // Copyright (C) 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
--- 1,4 ----
! // Copyright (C) 2006, 2007, 2008 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
*************** void test01()
*** 28,34 ****
  
    std::map<int, int> m;
  
!   VERIFY( m.max_size() == m.get_allocator().max_size() );
  }
  
  int main()
--- 28,35 ----
  
    std::map<int, int> m;
  
!   VERIFY( (m.max_size() == std::allocator<std::_Rb_tree_node<
! 	                   std::pair<const int, int> > >().max_size()) );
  }
  
  int main()

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