This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[v3] ... likewise for _Hashtable
- From: Paolo Carlini <paolo dot carlini at oracle dot com>
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Mon, 20 Oct 2008 18:45:09 +0200
- Subject: [v3] ... likewise for _Hashtable
Hi,
tested x86_64-linux, committed to mainline.
Paolo.
///////////////////
2008-10-20 Paolo Carlini <paolo.carlini@oracle.com>
* include/tr1_impl/hashtable_policy.h (_Hash_node<>::_Hash_node<>
(_Args&&...)): Add in C++0x mode.
* include/tr1_impl/hashtable (_Hashtable<>::_M_allocate_node,
_Hashtable<>::_M_deallocate_node): Use _M_get_Node_allocator in
C++0x mode.
* include/tr1_impl/hashtable (_Hashtable<>::max_size): Use
Node_allocator for improved accuracy.
* testsuite/tr1/6_containers/unordered_multimap/capacity/
29134-multimap.cc: Adjust.
* testsuite/tr1/6_containers/unordered_multimap/capacity/
29134-map.cc: Likewise.
* testsuite/tr1/6_containers/unordered_multimap/capacity/
29134-multiset.cc: Adjust.
* testsuite/tr1/6_containers/unordered_multimap/capacity/
29134-set.cc: Likewise.
Index: include/tr1_impl/hashtable
===================================================================
*** include/tr1_impl/hashtable (revision 141239)
--- include/tr1_impl/hashtable (working copy)
*************** _GLIBCXX_BEGIN_NAMESPACE_TR1
*** 296,302 ****
size_type
max_size() const
! { return _M_get_Value_allocator().max_size(); }
// Observers
key_equal
--- 296,302 ----
size_type
max_size() const
! { return _M_node_allocator.max_size(); }
// Observers
key_equal
*************** _GLIBCXX_BEGIN_NAMESPACE_TR1
*** 484,490 ****
--- 484,494 ----
_Node* __n = _M_node_allocator.allocate(1);
try
{
+ #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
+ _M_node_allocator.construct(__n, __v);
+ #else
_M_get_Value_allocator().construct(&__n->_M_v, __v);
+ #endif
__n->_M_next = 0;
return __n;
}
*************** _GLIBCXX_BEGIN_NAMESPACE_TR1
*** 504,510 ****
--- 508,518 ----
_H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>::
_M_deallocate_node(_Node* __n)
{
+ #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
+ _M_node_allocator.destroy(__n);
+ #else
_M_get_Value_allocator().destroy(&__n->_M_v);
+ #endif
_M_node_allocator.deallocate(__n, 1);
}
Index: include/tr1_impl/hashtable_policy.h
===================================================================
*** include/tr1_impl/hashtable_policy.h (revision 141239)
--- include/tr1_impl/hashtable_policy.h (working copy)
*************** namespace __detail
*** 99,104 ****
--- 99,111 ----
_Value _M_v;
std::size_t _M_hash_code;
_Hash_node* _M_next;
+
+ #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
+ template<typename... _Args>
+ _Hash_node(_Args&&... __args)
+ : _M_v(std::forward<_Args>(__args)...),
+ _M_hash_code(), _M_next() { }
+ #endif
};
template<typename _Value>
*************** namespace __detail
*** 106,111 ****
--- 113,125 ----
{
_Value _M_v;
_Hash_node* _M_next;
+
+ #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
+ template<typename... _Args>
+ _Hash_node(_Args&&... __args)
+ : _M_v(std::forward<_Args>(__args)...),
+ _M_next() { }
+ #endif
};
// Local iterators, used to iterate within a bucket but not between
Index: testsuite/tr1/6_containers/unordered_multimap/capacity/29134-multimap.cc
===================================================================
*** testsuite/tr1/6_containers/unordered_multimap/capacity/29134-multimap.cc (revision 141239)
--- testsuite/tr1/6_containers/unordered_multimap/capacity/29134-multimap.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::tr1::unordered_multimap<int, int> umm;
! VERIFY( umm.max_size() == umm.get_allocator().max_size() );
}
int main()
--- 28,35 ----
std::tr1::unordered_multimap<int, int> umm;
! VERIFY( (umm.max_size() == std::allocator<std::tr1::__detail::_Hash_node<
! std::pair<const int, int>, false> >().max_size()) );
}
int main()
Index: testsuite/tr1/6_containers/unordered_set/capacity/29134-set.cc
===================================================================
*** testsuite/tr1/6_containers/unordered_set/capacity/29134-set.cc (revision 141239)
--- testsuite/tr1/6_containers/unordered_set/capacity/29134-set.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::tr1::unordered_set<int> us;
! VERIFY( us.max_size() == us.get_allocator().max_size() );
}
int main()
--- 28,35 ----
std::tr1::unordered_set<int> us;
! VERIFY( (us.max_size() == std::allocator<std::tr1::__detail::_Hash_node<
! int, false> >().max_size()) );
}
int main()
Index: testsuite/tr1/6_containers/unordered_map/capacity/29134-map.cc
===================================================================
*** testsuite/tr1/6_containers/unordered_map/capacity/29134-map.cc (revision 141239)
--- testsuite/tr1/6_containers/unordered_map/capacity/29134-map.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::tr1::unordered_map<int, int> um;
! VERIFY( um.max_size() == um.get_allocator().max_size() );
}
int main()
--- 28,35 ----
std::tr1::unordered_map<int, int> um;
! VERIFY( (um.max_size() == std::allocator<std::tr1::__detail::_Hash_node<
! std::pair<const int, int>, false> >().max_size()));
}
int main()
Index: testsuite/tr1/6_containers/unordered_multiset/capacity/29134-multiset.cc
===================================================================
*** testsuite/tr1/6_containers/unordered_multiset/capacity/29134-multiset.cc (revision 141239)
--- testsuite/tr1/6_containers/unordered_multiset/capacity/29134-multiset.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::tr1::unordered_multiset<int> ums;
! VERIFY( ums.max_size() == ums.get_allocator().max_size() );
}
int main()
--- 28,35 ----
std::tr1::unordered_multiset<int> ums;
! VERIFY( (ums.max_size() == std::allocator<std::tr1::__detail::_Hash_node<
! int, false> >().max_size()) );
}
int main()