summaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/backward/hashtable.h
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2019-10-23 17:14:28 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2019-10-23 17:14:28 +0100
commit603aec6775d5191fafd57412364578db68432f74 (patch)
treeeecdf7326f959268b1d3a3dc997d14369a6b8f5a /libstdc++-v3/include/backward/hashtable.h
parent2ccbd21ded6eae4e099ccb1b5952dd3337875087 (diff)
downloadgcc-603aec6775d5191fafd57412364578db68432f74.tar.gz
Adjust extension types to use allocator_traits
This makes these extensions work with types meeting the Cpp17Allocator requirements as well as the C++98 Allocator requirements. * include/backward/hash_set (hash_set): Use __alloc_traits. * include/backward/hashtable.h (_Hashtable): Likewise. * include/ext/alloc_traits.h (__alloc_traits::allocate): Add overload taking a hint. * include/ext/extptr_allocator.h (_ExtPtr_allocator::allocate): Ignore hint. * include/ext/slist (_Slist_base): Use __alloc_traits. * include/tr1/hashtable.h (_Hashtable): Likewise. * include/tr1/regex (match_results): Use vector::const_reference instead of assuming the allocator defines it. * testsuite/backward/hash_map/23528.cc: Use allocator_traits in C++11. * testsuite/tr1/6_containers/unordered_map/capacity/29134-map.cc: Use __gnu_test::max_size. * testsuite/tr1/6_containers/unordered_multimap/capacity/ 29134-multimap.cc: Likewise. * testsuite/tr1/6_containers/unordered_multiset/capacity/ 29134-multiset.cc: Likewise. * testsuite/tr1/6_containers/unordered_set/capacity/29134-set.cc: Likewise. From-SVN: r277335
Diffstat (limited to 'libstdc++-v3/include/backward/hashtable.h')
-rw-r--r--libstdc++-v3/include/backward/hashtable.h18
1 files changed, 13 insertions, 5 deletions
diff --git a/libstdc++-v3/include/backward/hashtable.h b/libstdc++-v3/include/backward/hashtable.h
index df6ad85191c..cfb9cf957d2 100644
--- a/libstdc++-v3/include/backward/hashtable.h
+++ b/libstdc++-v3/include/backward/hashtable.h
@@ -63,6 +63,7 @@
#include <iterator>
#include <algorithm>
#include <bits/stl_function.h>
+#include <ext/alloc_traits.h>
#include <backward/hash_fun.h>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
@@ -280,14 +281,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef _Hashtable_node<_Val> _Node;
public:
- typedef typename _Alloc::template rebind<value_type>::other allocator_type;
+ typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template
+ rebind<value_type>::other allocator_type;
+
allocator_type
get_allocator() const
{ return _M_node_allocator; }
private:
- typedef typename _Alloc::template rebind<_Node>::other _Node_Alloc;
- typedef typename _Alloc::template rebind<_Node*>::other _Nodeptr_Alloc;
+ typedef __gnu_cxx::__alloc_traits<allocator_type> _Alloc_traits;
+ typedef typename _Alloc_traits::template rebind<_Node>::other
+ _Node_Alloc;
+ typedef typename _Alloc_traits::template rebind<_Node*>::other
+ _Nodeptr_Alloc;
typedef std::vector<_Node*, _Nodeptr_Alloc> _Vector_type;
_Node_Alloc _M_node_allocator;
@@ -608,7 +614,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__n->_M_next = 0;
__try
{
- this->get_allocator().construct(&__n->_M_val, __obj);
+ allocator_type __a = this->get_allocator();
+ _Alloc_traits::construct(__a, &__n->_M_val, __obj);
return __n;
}
__catch(...)
@@ -621,7 +628,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
void
_M_delete_node(_Node* __n)
{
- this->get_allocator().destroy(&__n->_M_val);
+ allocator_type __a = this->get_allocator();
+ _Alloc_traits::destroy(__a, &__n->_M_val);
_M_put_node(__n);
}