31 #ifndef _HASHTABLE_POLICY_H
32 #define _HASHTABLE_POLICY_H 1
38 namespace std _GLIBCXX_VISIBILITY(default)
40 _GLIBCXX_BEGIN_NAMESPACE_VERSION
43 template<
typename _Key,
typename _Value,
typename _Alloc,
44 typename _ExtractKey,
typename _Equal,
45 typename _Hash,
typename _RangeHash,
typename _Unused,
46 typename _RehashPolicy,
typename _Traits>
56 template<
typename _Key,
typename _Value,
typename _ExtractKey,
57 typename _Equal,
typename _Hash,
typename _RangeHash,
58 typename _Unused,
typename _Traits>
59 struct _Hashtable_base;
63 template<
typename _Iterator>
65 __distance_fw(_Iterator __first, _Iterator __last,
67 {
return __first != __last ? 1 : 0; }
69 template<
typename _Iterator>
71 __distance_fw(_Iterator __first, _Iterator __last,
75 template<
typename _Iterator>
77 __distance_fw(_Iterator __first, _Iterator __last)
78 {
return __distance_fw(__first, __last,
83 template<
typename _Tp>
85 operator()(_Tp&& __x)
const noexcept
86 {
return std::forward<_Tp>(__x); }
91 template<
typename _Pair>
94 template<
typename _Tp,
typename _Up>
95 struct __1st_type<pair<_Tp, _Up>>
96 {
using type = _Tp; };
98 template<
typename _Tp,
typename _Up>
99 struct __1st_type<const pair<_Tp, _Up>>
100 {
using type =
const _Tp; };
102 template<
typename _Pair>
103 struct __1st_type<_Pair&>
104 {
using type =
typename __1st_type<_Pair>::type&; };
106 template<
typename _Tp>
107 typename __1st_type<_Tp>::type&&
108 operator()(_Tp&& __x)
const noexcept
109 {
return std::forward<_Tp>(__x).first; }
112 template<
typename _ExKey>
116 struct _NodeBuilder<_Select1st>
118 template<
typename _Kt,
typename _Arg,
typename _NodeGenerator>
120 _S_build(_Kt&& __k, _Arg&& __arg,
const _NodeGenerator& __node_gen)
121 ->
typename _NodeGenerator::__node_type*
123 return __node_gen(std::forward<_Kt>(__k),
124 std::forward<_Arg>(__arg).second);
129 struct _NodeBuilder<_Identity>
131 template<
typename _Kt,
typename _Arg,
typename _NodeGenerator>
133 _S_build(_Kt&& __k, _Arg&&,
const _NodeGenerator& __node_gen)
134 ->
typename _NodeGenerator::__node_type*
135 {
return __node_gen(std::forward<_Kt>(__k)); }
138 template<
typename _NodeAlloc>
139 struct _Hashtable_alloc;
143 template<
typename _NodeAlloc>
144 struct _ReuseOrAllocNode
147 using __node_alloc_type = _NodeAlloc;
148 using __hashtable_alloc = _Hashtable_alloc<__node_alloc_type>;
149 using __node_alloc_traits =
150 typename __hashtable_alloc::__node_alloc_traits;
153 using __node_type =
typename __hashtable_alloc::__node_type;
155 _ReuseOrAllocNode(__node_type* __nodes, __hashtable_alloc& __h)
156 : _M_nodes(__nodes), _M_h(__h) { }
157 _ReuseOrAllocNode(
const _ReuseOrAllocNode&) =
delete;
160 { _M_h._M_deallocate_nodes(_M_nodes); }
162 template<
typename... _Args>
164 operator()(_Args&&... __args)
const
168 __node_type* __node = _M_nodes;
169 _M_nodes = _M_nodes->_M_next();
170 __node->_M_nxt =
nullptr;
171 auto& __a = _M_h._M_node_allocator();
172 __node_alloc_traits::destroy(__a, __node->_M_valptr());
175 __node_alloc_traits::construct(__a, __node->_M_valptr(),
176 std::forward<_Args>(__args)...);
180 _M_h._M_deallocate_node_ptr(__node);
181 __throw_exception_again;
185 return _M_h._M_allocate_node(std::forward<_Args>(__args)...);
189 mutable __node_type* _M_nodes;
190 __hashtable_alloc& _M_h;
195 template<
typename _NodeAlloc>
199 using __hashtable_alloc = _Hashtable_alloc<_NodeAlloc>;
202 using __node_type =
typename __hashtable_alloc::__node_type;
204 _AllocNode(__hashtable_alloc& __h)
207 template<
typename... _Args>
209 operator()(_Args&&... __args)
const
210 {
return _M_h._M_allocate_node(std::forward<_Args>(__args)...); }
213 __hashtable_alloc& _M_h;
241 template<
bool _Cache_hash_code,
bool _Constant_iterators,
bool _Unique_keys>
242 struct _Hashtable_traits
244 using __hash_cached = __bool_constant<_Cache_hash_code>;
245 using __constant_iterators = __bool_constant<_Constant_iterators>;
246 using __unique_keys = __bool_constant<_Unique_keys>;
257 struct _Hash_node_base
259 _Hash_node_base* _M_nxt;
261 _Hash_node_base() noexcept : _M_nxt() { }
263 _Hash_node_base(_Hash_node_base* __next) noexcept : _M_nxt(__next) { }
271 template<
typename _Value>
272 struct _Hash_node_value_base
274 typedef _Value value_type;
276 __gnu_cxx::__aligned_buffer<_Value> _M_storage;
280 {
return _M_storage._M_ptr(); }
283 _M_valptr() const noexcept
284 {
return _M_storage._M_ptr(); }
288 {
return *_M_valptr(); }
291 _M_v() const noexcept
292 {
return *_M_valptr(); }
298 template<
bool _Cache_hash_code>
299 struct _Hash_node_code_cache
306 struct _Hash_node_code_cache<true>
307 { std::size_t _M_hash_code; };
309 template<
typename _Value,
bool _Cache_hash_code>
310 struct _Hash_node_value
311 : _Hash_node_value_base<_Value>
312 , _Hash_node_code_cache<_Cache_hash_code>
318 template<
typename _Value,
bool _Cache_hash_code>
321 , _Hash_node_value<_Value, _Cache_hash_code>
324 _M_next() const noexcept
325 {
return static_cast<_Hash_node*
>(this->_M_nxt); }
329 template<
typename _Value,
bool _Cache_hash_code>
330 struct _Node_iterator_base
332 using __node_type = _Hash_node<_Value, _Cache_hash_code>;
336 _Node_iterator_base() : _M_cur(nullptr) { }
337 _Node_iterator_base(__node_type* __p) noexcept
342 { _M_cur = _M_cur->_M_next(); }
345 operator==(
const _Node_iterator_base& __x,
const _Node_iterator_base& __y)
347 {
return __x._M_cur == __y._M_cur; }
349 #if __cpp_impl_three_way_comparison < 201907L
351 operator!=(
const _Node_iterator_base& __x,
const _Node_iterator_base& __y)
353 {
return __x._M_cur != __y._M_cur; }
358 template<
typename _Value,
bool __constant_iterators,
bool __cache>
359 struct _Node_iterator
360 :
public _Node_iterator_base<_Value, __cache>
363 using __base_type = _Node_iterator_base<_Value, __cache>;
364 using __node_type =
typename __base_type::__node_type;
367 using value_type = _Value;
368 using difference_type = std::ptrdiff_t;
371 using pointer = __conditional_t<__constant_iterators,
372 const value_type*, value_type*>;
374 using reference = __conditional_t<__constant_iterators,
375 const value_type&, value_type&>;
377 _Node_iterator() =
default;
380 _Node_iterator(__node_type* __p) noexcept
381 : __base_type(__p) { }
385 {
return this->_M_cur->_M_v(); }
388 operator->() const noexcept
389 {
return this->_M_cur->_M_valptr(); }
392 operator++() noexcept
399 operator++(
int) noexcept
401 _Node_iterator __tmp(*
this);
408 template<
typename _Value,
bool __constant_iterators,
bool __cache>
409 struct _Node_const_iterator
410 :
public _Node_iterator_base<_Value, __cache>
413 using __base_type = _Node_iterator_base<_Value, __cache>;
414 using __node_type =
typename __base_type::__node_type;
417 typedef _Value value_type;
418 typedef std::ptrdiff_t difference_type;
421 typedef const value_type* pointer;
422 typedef const value_type& reference;
424 _Node_const_iterator() =
default;
427 _Node_const_iterator(__node_type* __p) noexcept
428 : __base_type(__p) { }
430 _Node_const_iterator(
const _Node_iterator<_Value, __constant_iterators,
431 __cache>& __x) noexcept
432 : __base_type(__x._M_cur) { }
436 {
return this->_M_cur->_M_v(); }
439 operator->() const noexcept
440 {
return this->_M_cur->_M_valptr(); }
442 _Node_const_iterator&
443 operator++() noexcept
450 operator++(
int) noexcept
452 _Node_const_iterator __tmp(*
this);
463 struct _Mod_range_hashing
465 typedef std::size_t first_argument_type;
466 typedef std::size_t second_argument_type;
467 typedef std::size_t result_type;
470 operator()(first_argument_type __num,
471 second_argument_type __den)
const noexcept
472 {
return __num % __den; }
480 struct _Default_ranged_hash { };
484 struct _Prime_rehash_policy
488 _Prime_rehash_policy(
float __z = 1.0) noexcept
489 : _M_max_load_factor(__z), _M_next_resize(0) { }
492 max_load_factor() const noexcept
493 {
return _M_max_load_factor; }
497 _M_next_bkt(std::size_t __n)
const;
501 _M_bkt_for_elements(std::size_t __n)
const
502 {
return __builtin_ceil(__n / (
double)_M_max_load_factor); }
509 _M_need_rehash(std::size_t __n_bkt, std::size_t __n_elt,
510 std::size_t __n_ins)
const;
512 typedef std::size_t _State;
516 {
return _M_next_resize; }
520 { _M_next_resize = 0; }
523 _M_reset(_State __state)
524 { _M_next_resize = __state; }
526 static const std::size_t _S_growth_factor = 2;
528 float _M_max_load_factor;
529 mutable std::size_t _M_next_resize;
533 struct _Mask_range_hashing
535 typedef std::size_t first_argument_type;
536 typedef std::size_t second_argument_type;
537 typedef std::size_t result_type;
540 operator()(first_argument_type __num,
541 second_argument_type __den)
const noexcept
542 {
return __num & (__den - 1); }
547 __clp2(std::size_t __n) noexcept
553 const unsigned __lz =
sizeof(size_t) >
sizeof(
long)
554 ? __builtin_clzll(__n - 1ull)
555 : __builtin_clzl(__n - 1ul);
557 return (
size_t(1) << (__int_traits<size_t>::__digits - __lz - 1)) << 1;
562 struct _Power2_rehash_policy
566 _Power2_rehash_policy(
float __z = 1.0) noexcept
567 : _M_max_load_factor(__z), _M_next_resize(0) { }
570 max_load_factor() const noexcept
571 {
return _M_max_load_factor; }
576 _M_next_bkt(std::size_t __n) noexcept
584 const auto __max_width = std::min<size_t>(
sizeof(
size_t), 8);
585 const auto __max_bkt = size_t(1) << (__max_width * __CHAR_BIT__ - 1);
586 std::size_t __res = __clp2(__n);
596 if (__res == __max_bkt)
600 _M_next_resize = size_t(-1);
603 = __builtin_floor(__res * (
double)_M_max_load_factor);
610 _M_bkt_for_elements(std::size_t __n)
const noexcept
611 {
return __builtin_ceil(__n / (
double)_M_max_load_factor); }
618 _M_need_rehash(std::size_t __n_bkt, std::size_t __n_elt,
619 std::size_t __n_ins) noexcept
621 if (__n_elt + __n_ins > _M_next_resize)
627 = std::max<std::size_t>(__n_elt + __n_ins, _M_next_resize ? 0 : 11)
628 / (double)_M_max_load_factor;
629 if (__min_bkts >= __n_bkt)
631 _M_next_bkt(std::max<std::size_t>(__builtin_floor(__min_bkts) + 1,
632 __n_bkt * _S_growth_factor)) };
635 = __builtin_floor(__n_bkt * (
double)_M_max_load_factor);
642 typedef std::size_t _State;
645 _M_state() const noexcept
646 {
return _M_next_resize; }
650 { _M_next_resize = 0; }
653 _M_reset(_State __state) noexcept
654 { _M_next_resize = __state; }
656 static const std::size_t _S_growth_factor = 2;
658 float _M_max_load_factor;
659 std::size_t _M_next_resize;
680 template<
typename _Key,
typename _Value,
typename _Alloc,
681 typename _ExtractKey,
typename _Equal,
682 typename _Hash,
typename _RangeHash,
typename _Unused,
683 typename _RehashPolicy,
typename _Traits,
684 bool _Unique_keys = _Traits::__unique_keys::value>
685 struct _Map_base { };
688 template<
typename _Key,
typename _Val,
typename _Alloc,
typename _Equal,
689 typename _Hash,
typename _RangeHash,
typename _Unused,
690 typename _RehashPolicy,
typename _Traits>
691 struct _Map_base<_Key, pair<const _Key, _Val>, _Alloc, _Select1st, _Equal,
692 _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, false>
694 using mapped_type = _Val;
698 template<
typename _Key,
typename _Val,
typename _Alloc,
typename _Equal,
699 typename _Hash,
typename _RangeHash,
typename _Unused,
700 typename _RehashPolicy,
typename _Traits>
701 struct _Map_base<_Key, pair<const _Key, _Val>, _Alloc, _Select1st, _Equal,
702 _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, true>
705 using __hashtable_base = _Hashtable_base<_Key, pair<const _Key, _Val>,
706 _Select1st, _Equal, _Hash,
710 using __hashtable = _Hashtable<_Key, pair<const _Key, _Val>, _Alloc,
711 _Select1st, _Equal, _Hash, _RangeHash,
712 _Unused, _RehashPolicy, _Traits>;
714 using __hash_code =
typename __hashtable_base::__hash_code;
717 using key_type =
typename __hashtable_base::key_type;
718 using mapped_type = _Val;
721 operator[](
const key_type& __k);
724 operator[](key_type&& __k);
729 at(
const key_type& __k)
731 auto __ite =
static_cast<__hashtable*
>(
this)->find(__k);
733 __throw_out_of_range(__N(
"unordered_map::at"));
734 return __ite->second;
738 at(
const key_type& __k)
const
740 auto __ite =
static_cast<const __hashtable*
>(
this)->find(__k);
742 __throw_out_of_range(__N(
"unordered_map::at"));
743 return __ite->second;
747 template<
typename _Key,
typename _Val,
typename _Alloc,
typename _Equal,
748 typename _Hash,
typename _RangeHash,
typename _Unused,
749 typename _RehashPolicy,
typename _Traits>
751 _Map_base<_Key, pair<const _Key, _Val>, _Alloc, _Select1st, _Equal,
752 _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits,
true>::
753 operator[](
const key_type& __k)
756 __hashtable* __h =
static_cast<__hashtable*
>(
this);
757 __hash_code __code = __h->_M_hash_code(__k);
758 std::size_t __bkt = __h->_M_bucket_index(__code);
759 if (
auto __node = __h->_M_find_node(__bkt, __k, __code))
760 return __node->_M_v().second;
762 typename __hashtable::_Scoped_node __node {
769 = __h->_M_insert_unique_node(__bkt, __code, __node._M_node);
770 __node._M_node =
nullptr;
771 return __pos->second;
774 template<
typename _Key,
typename _Val,
typename _Alloc,
typename _Equal,
775 typename _Hash,
typename _RangeHash,
typename _Unused,
776 typename _RehashPolicy,
typename _Traits>
778 _Map_base<_Key, pair<const _Key, _Val>, _Alloc, _Select1st, _Equal,
779 _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits,
true>::
780 operator[](key_type&& __k)
783 __hashtable* __h =
static_cast<__hashtable*
>(
this);
784 __hash_code __code = __h->_M_hash_code(__k);
785 std::size_t __bkt = __h->_M_bucket_index(__code);
786 if (
auto __node = __h->_M_find_node(__bkt, __k, __code))
787 return __node->_M_v().second;
789 typename __hashtable::_Scoped_node __node {
796 = __h->_M_insert_unique_node(__bkt, __code, __node._M_node);
797 __node._M_node =
nullptr;
798 return __pos->second;
806 template<
typename _Key,
typename _Value,
typename _Alloc,
807 typename _ExtractKey,
typename _Equal,
808 typename _Hash,
typename _RangeHash,
typename _Unused,
809 typename _RehashPolicy,
typename _Traits>
813 using __hashtable_base = _Hashtable_base<_Key, _Value, _ExtractKey,
814 _Equal, _Hash, _RangeHash,
817 using __hashtable = _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
819 _Unused, _RehashPolicy, _Traits>;
821 using __hash_cached =
typename _Traits::__hash_cached;
822 using __constant_iterators =
typename _Traits::__constant_iterators;
824 using __hashtable_alloc = _Hashtable_alloc<
825 __alloc_rebind<_Alloc, _Hash_node<_Value,
826 __hash_cached::value>>>;
828 using value_type =
typename __hashtable_base::value_type;
829 using size_type =
typename __hashtable_base::size_type;
831 using __unique_keys =
typename _Traits::__unique_keys;
832 using __node_alloc_type =
typename __hashtable_alloc::__node_alloc_type;
833 using __node_gen_type = _AllocNode<__node_alloc_type>;
836 _M_conjure_hashtable()
837 {
return *(
static_cast<__hashtable*
>(
this)); }
839 template<
typename _InputIterator,
typename _NodeGetter>
841 _M_insert_range(_InputIterator __first, _InputIterator __last,
844 template<
typename _InputIterator,
typename _NodeGetter>
846 _M_insert_range(_InputIterator __first, _InputIterator __last,
850 using iterator = _Node_iterator<_Value, __constant_iterators::value,
851 __hash_cached::value>;
853 using const_iterator = _Node_const_iterator<_Value,
854 __constant_iterators::value,
855 __hash_cached::value>;
857 using __ireturn_type = __conditional_t<__unique_keys::value,
862 insert(
const value_type& __v)
864 __hashtable& __h = _M_conjure_hashtable();
865 __node_gen_type __node_gen(__h);
866 return __h._M_insert(__v, __node_gen, __unique_keys{});
870 insert(const_iterator __hint,
const value_type& __v)
872 __hashtable& __h = _M_conjure_hashtable();
873 __node_gen_type __node_gen(__h);
874 return __h._M_insert(__hint, __v, __node_gen, __unique_keys{});
877 template<
typename _KType,
typename... _Args>
879 try_emplace(const_iterator, _KType&& __k, _Args&&... __args)
881 __hashtable& __h = _M_conjure_hashtable();
882 auto __code = __h._M_hash_code(__k);
883 std::size_t __bkt = __h._M_bucket_index(__code);
884 if (
auto __node = __h._M_find_node(__bkt, __k, __code))
885 return { iterator(__node),
false };
887 typename __hashtable::_Scoped_node __node {
894 = __h._M_insert_unique_node(__bkt, __code, __node._M_node);
895 __node._M_node =
nullptr;
896 return { __it,
true };
900 insert(initializer_list<value_type> __l)
901 { this->insert(__l.begin(), __l.end()); }
903 template<
typename _InputIterator>
905 insert(_InputIterator __first, _InputIterator __last)
907 __hashtable& __h = _M_conjure_hashtable();
908 __node_gen_type __node_gen(__h);
909 return _M_insert_range(__first, __last, __node_gen, __unique_keys{});
913 template<
typename _Key,
typename _Value,
typename _Alloc,
914 typename _ExtractKey,
typename _Equal,
915 typename _Hash,
typename _RangeHash,
typename _Unused,
916 typename _RehashPolicy,
typename _Traits>
917 template<
typename _InputIterator,
typename _NodeGetter>
919 _Insert_base<_Key, _Value, _Alloc, _ExtractKey, _Equal,
920 _Hash, _RangeHash, _Unused,
921 _RehashPolicy, _Traits>::
922 _M_insert_range(_InputIterator __first, _InputIterator __last,
923 const _NodeGetter& __node_gen,
true_type __uks)
925 __hashtable& __h = _M_conjure_hashtable();
926 for (; __first != __last; ++__first)
927 __h._M_insert(*__first, __node_gen, __uks);
930 template<
typename _Key,
typename _Value,
typename _Alloc,
931 typename _ExtractKey,
typename _Equal,
932 typename _Hash,
typename _RangeHash,
typename _Unused,
933 typename _RehashPolicy,
typename _Traits>
934 template<
typename _InputIterator,
typename _NodeGetter>
936 _Insert_base<_Key, _Value, _Alloc, _ExtractKey, _Equal,
937 _Hash, _RangeHash, _Unused,
938 _RehashPolicy, _Traits>::
939 _M_insert_range(_InputIterator __first, _InputIterator __last,
940 const _NodeGetter& __node_gen,
false_type __uks)
942 using __rehash_type =
typename __hashtable::__rehash_type;
943 using __rehash_state =
typename __hashtable::__rehash_state;
946 size_type __n_elt = __detail::__distance_fw(__first, __last);
950 __hashtable& __h = _M_conjure_hashtable();
951 __rehash_type& __rehash = __h._M_rehash_policy;
952 const __rehash_state& __saved_state = __rehash._M_state();
953 pair_type __do_rehash = __rehash._M_need_rehash(__h._M_bucket_count,
954 __h._M_element_count,
957 if (__do_rehash.first)
958 __h._M_rehash(__do_rehash.second, __saved_state);
960 for (; __first != __last; ++__first)
961 __h._M_insert(*__first, __node_gen, __uks);
970 template<
typename _Key,
typename _Value,
typename _Alloc,
971 typename _ExtractKey,
typename _Equal,
972 typename _Hash,
typename _RangeHash,
typename _Unused,
973 typename _RehashPolicy,
typename _Traits,
974 bool _Constant_iterators = _Traits::__constant_iterators::value>
978 template<
typename _Key,
typename _Value,
typename _Alloc,
979 typename _ExtractKey,
typename _Equal,
980 typename _Hash,
typename _RangeHash,
typename _Unused,
981 typename _RehashPolicy,
typename _Traits>
982 struct _Insert<_Key, _Value, _Alloc, _ExtractKey, _Equal,
983 _Hash, _RangeHash, _Unused,
984 _RehashPolicy, _Traits, true>
985 :
public _Insert_base<_Key, _Value, _Alloc, _ExtractKey, _Equal,
986 _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>
988 using __base_type = _Insert_base<_Key, _Value, _Alloc, _ExtractKey,
989 _Equal, _Hash, _RangeHash, _Unused,
990 _RehashPolicy, _Traits>;
992 using value_type =
typename __base_type::value_type;
993 using iterator =
typename __base_type::iterator;
994 using const_iterator =
typename __base_type::const_iterator;
995 using __ireturn_type =
typename __base_type::__ireturn_type;
997 using __unique_keys =
typename __base_type::__unique_keys;
998 using __hashtable =
typename __base_type::__hashtable;
999 using __node_gen_type =
typename __base_type::__node_gen_type;
1001 using __base_type::insert;
1004 insert(value_type&& __v)
1006 __hashtable& __h = this->_M_conjure_hashtable();
1007 __node_gen_type __node_gen(__h);
1008 return __h._M_insert(
std::move(__v), __node_gen, __unique_keys{});
1012 insert(const_iterator __hint, value_type&& __v)
1014 __hashtable& __h = this->_M_conjure_hashtable();
1015 __node_gen_type __node_gen(__h);
1016 return __h._M_insert(__hint,
std::move(__v), __node_gen,
1022 template<
typename _Key,
typename _Value,
typename _Alloc,
1023 typename _ExtractKey,
typename _Equal,
1024 typename _Hash,
typename _RangeHash,
typename _Unused,
1025 typename _RehashPolicy,
typename _Traits>
1026 struct _Insert<_Key, _Value, _Alloc, _ExtractKey, _Equal,
1027 _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, false>
1028 :
public _Insert_base<_Key, _Value, _Alloc, _ExtractKey, _Equal,
1029 _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>
1031 using __base_type = _Insert_base<_Key, _Value, _Alloc, _ExtractKey,
1032 _Equal, _Hash, _RangeHash, _Unused,
1033 _RehashPolicy, _Traits>;
1034 using value_type =
typename __base_type::value_type;
1035 using iterator =
typename __base_type::iterator;
1036 using const_iterator =
typename __base_type::const_iterator;
1038 using __unique_keys =
typename __base_type::__unique_keys;
1039 using __hashtable =
typename __base_type::__hashtable;
1040 using __ireturn_type =
typename __base_type::__ireturn_type;
1042 using __base_type::insert;
1044 template<
typename _Pair>
1047 template<
typename _Pair>
1050 template<
typename _Pair>
1051 using _IFconsp =
typename _IFcons<_Pair>::type;
1053 template<
typename _Pair,
typename = _IFconsp<_Pair>>
1057 __hashtable& __h = this->_M_conjure_hashtable();
1058 return __h._M_emplace(__unique_keys{}, std::forward<_Pair>(__v));
1061 template<
typename _Pair,
typename = _IFconsp<_Pair>>
1063 insert(const_iterator __hint, _Pair&& __v)
1065 __hashtable& __h = this->_M_conjure_hashtable();
1066 return __h._M_emplace(__hint, __unique_keys{},
1067 std::forward<_Pair>(__v));
1071 template<
typename _Policy>
1072 using __has_load_factor =
typename _Policy::__has_load_factor;
1080 template<
typename _Key,
typename _Value,
typename _Alloc,
1081 typename _ExtractKey,
typename _Equal,
1082 typename _Hash,
typename _RangeHash,
typename _Unused,
1083 typename _RehashPolicy,
typename _Traits,
1085 __detected_or_t<false_type, __has_load_factor, _RehashPolicy>>
1086 struct _Rehash_base;
1089 template<
typename _Key,
typename _Value,
typename _Alloc,
1090 typename _ExtractKey,
typename _Equal,
1091 typename _Hash,
typename _RangeHash,
typename _Unused,
1092 typename _RehashPolicy,
typename _Traits>
1093 struct _Rehash_base<_Key, _Value, _Alloc, _ExtractKey, _Equal,
1094 _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits,
1100 template<
typename _Key,
typename _Value,
typename _Alloc,
1101 typename _ExtractKey,
typename _Equal,
1102 typename _Hash,
typename _RangeHash,
typename _Unused,
1103 typename _RehashPolicy,
typename _Traits>
1104 struct _Rehash_base<_Key, _Value, _Alloc, _ExtractKey, _Equal,
1105 _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits,
1108 using __hashtable = _Hashtable<_Key, _Value, _Alloc, _ExtractKey,
1109 _Equal, _Hash, _RangeHash, _Unused,
1110 _RehashPolicy, _Traits>;
1113 max_load_factor() const noexcept
1115 const __hashtable* __this =
static_cast<const __hashtable*
>(
this);
1116 return __this->__rehash_policy().max_load_factor();
1120 max_load_factor(
float __z)
1122 __hashtable* __this =
static_cast<__hashtable*
>(
this);
1123 __this->__rehash_policy(_RehashPolicy(__z));
1127 reserve(std::size_t __n)
1129 __hashtable* __this =
static_cast<__hashtable*
>(
this);
1130 __this->rehash(__this->__rehash_policy()._M_bkt_for_elements(__n));
1140 template<
int _Nm,
typename _Tp,
1141 bool __use_ebo = !__is_final(_Tp) && __is_empty(_Tp)>
1142 struct _Hashtable_ebo_helper;
1145 template<
int _Nm,
typename _Tp>
1146 struct _Hashtable_ebo_helper<_Nm, _Tp, true>
1149 _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { }
1151 template<
typename _OtherTp>
1152 _Hashtable_ebo_helper(_OtherTp&& __tp)
1156 const _Tp& _M_cget()
const {
return static_cast<const _Tp&
>(*this); }
1157 _Tp& _M_get() {
return static_cast<_Tp&
>(*this); }
1161 template<
int _Nm,
typename _Tp>
1162 struct _Hashtable_ebo_helper<_Nm, _Tp, false>
1164 _Hashtable_ebo_helper() =
default;
1166 template<
typename _OtherTp>
1167 _Hashtable_ebo_helper(_OtherTp&& __tp)
1171 const _Tp& _M_cget()
const {
return _M_tp; }
1172 _Tp& _M_get() {
return _M_tp; }
1184 template<
typename _Key,
typename _Value,
typename _ExtractKey,
1185 typename _Hash,
typename _RangeHash,
typename _Unused,
1186 bool __cache_hash_code>
1187 struct _Local_iterator_base;
1207 template<
typename _Key,
typename _Value,
typename _ExtractKey,
1208 typename _Hash,
typename _RangeHash,
typename _Unused,
1209 bool __cache_hash_code>
1210 struct _Hash_code_base
1211 :
private _Hashtable_ebo_helper<1, _Hash>
1214 using __ebo_hash = _Hashtable_ebo_helper<1, _Hash>;
1217 friend struct _Local_iterator_base<_Key, _Value, _ExtractKey,
1218 _Hash, _RangeHash, _Unused, false>;
1221 typedef _Hash hasher;
1224 hash_function()
const
1225 {
return _M_hash(); }
1228 typedef std::size_t __hash_code;
1232 _Hash_code_base() =
default;
1234 _Hash_code_base(
const _Hash& __hash) : __ebo_hash(__hash) { }
1237 _M_hash_code(
const _Key& __k)
const
1239 static_assert(__is_invocable<const _Hash&, const _Key&>{},
1240 "hash function must be invocable with an argument of key type");
1241 return _M_hash()(__k);
1244 template<
typename _Kt>
1246 _M_hash_code_tr(
const _Kt& __k)
const
1248 static_assert(__is_invocable<const _Hash&, const _Kt&>{},
1249 "hash function must be invocable with an argument of key type");
1250 return _M_hash()(__k);
1254 _M_hash_code(
const _Hash&,
1255 const _Hash_node_value<_Value, true>& __n)
const
1256 {
return __n._M_hash_code; }
1260 template<
typename _H2>
1262 _M_hash_code(
const _H2&,
1263 const _Hash_node_value<_Value, __cache_hash_code>& __n)
const
1264 {
return _M_hash_code(_ExtractKey{}(__n._M_v())); }
1267 _M_bucket_index(__hash_code __c, std::size_t __bkt_count)
const
1268 {
return _RangeHash{}(__c, __bkt_count); }
1271 _M_bucket_index(
const _Hash_node_value<_Value, false>& __n,
1272 std::size_t __bkt_count)
const
1273 noexcept( noexcept(declval<const _Hash&>()(declval<const _Key&>()))
1274 && noexcept(declval<const _RangeHash&>()((__hash_code)0,
1277 return _RangeHash{}(_M_hash_code(_ExtractKey{}(__n._M_v())),
1282 _M_bucket_index(
const _Hash_node_value<_Value, true>& __n,
1283 std::size_t __bkt_count)
const
1284 noexcept( noexcept(declval<const _RangeHash&>()((__hash_code)0,
1286 {
return _RangeHash{}(__n._M_hash_code, __bkt_count); }
1289 _M_store_code(_Hash_node_code_cache<false>&, __hash_code)
const
1293 _M_copy_code(_Hash_node_code_cache<false>&,
1294 const _Hash_node_code_cache<false>&)
const
1298 _M_store_code(_Hash_node_code_cache<true>& __n, __hash_code __c)
const
1299 { __n._M_hash_code = __c; }
1302 _M_copy_code(_Hash_node_code_cache<true>& __to,
1303 const _Hash_node_code_cache<true>& __from)
const
1304 { __to._M_hash_code = __from._M_hash_code; }
1307 _M_swap(_Hash_code_base& __x)
1308 {
std::swap(__ebo_hash::_M_get(), __x.__ebo_hash::_M_get()); }
1311 _M_hash()
const {
return __ebo_hash::_M_cget(); }
1315 template<
typename _Key,
typename _Value,
typename _ExtractKey,
1316 typename _Hash,
typename _RangeHash,
typename _Unused>
1317 struct _Local_iterator_base<_Key, _Value, _ExtractKey,
1318 _Hash, _RangeHash, _Unused, true>
1319 :
public _Node_iterator_base<_Value, true>
1322 using __base_node_iter = _Node_iterator_base<_Value, true>;
1323 using __hash_code_base = _Hash_code_base<_Key, _Value, _ExtractKey,
1324 _Hash, _RangeHash, _Unused,
true>;
1326 _Local_iterator_base() =
default;
1327 _Local_iterator_base(
const __hash_code_base&,
1328 _Hash_node<_Value, true>* __p,
1329 std::size_t __bkt, std::size_t __bkt_count)
1330 : __base_node_iter(__p), _M_bucket(__bkt), _M_bucket_count(__bkt_count)
1336 __base_node_iter::_M_incr();
1340 = _RangeHash{}(this->_M_cur->_M_hash_code, _M_bucket_count);
1341 if (__bkt != _M_bucket)
1342 this->_M_cur =
nullptr;
1346 std::size_t _M_bucket;
1347 std::size_t _M_bucket_count;
1351 _M_get_bucket()
const {
return _M_bucket; }
1358 template<typename _Tp, bool _IsEmpty = std::is_empty<_Tp>::value>
1359 struct _Hash_code_storage
1361 __gnu_cxx::__aligned_buffer<_Tp> _M_storage;
1364 _M_h() {
return _M_storage._M_ptr(); }
1367 _M_h()
const {
return _M_storage._M_ptr(); }
1371 template<
typename _Tp>
1372 struct _Hash_code_storage<_Tp, true>
1379 _M_h() {
return reinterpret_cast<_Tp*
>(
this); }
1382 _M_h()
const {
return reinterpret_cast<const _Tp*
>(
this); }
1385 template<
typename _Key,
typename _Value,
typename _ExtractKey,
1386 typename _Hash,
typename _RangeHash,
typename _Unused>
1387 using __hash_code_for_local_iter
1388 = _Hash_code_storage<_Hash_code_base<_Key, _Value, _ExtractKey,
1389 _Hash, _RangeHash, _Unused,
false>>;
1392 template<
typename _Key,
typename _Value,
typename _ExtractKey,
1393 typename _Hash,
typename _RangeHash,
typename _Unused>
1394 struct _Local_iterator_base<_Key, _Value, _ExtractKey,
1395 _Hash, _RangeHash, _Unused, false>
1396 : __hash_code_for_local_iter<_Key, _Value, _ExtractKey, _Hash, _RangeHash,
1398 , _Node_iterator_base<_Value, false>
1401 using __hash_code_base = _Hash_code_base<_Key, _Value, _ExtractKey,
1402 _Hash, _RangeHash, _Unused,
false>;
1403 using __node_iter_base = _Node_iterator_base<_Value, false>;
1405 _Local_iterator_base() : _M_bucket_count(-1) { }
1407 _Local_iterator_base(
const __hash_code_base&
__base,
1408 _Hash_node<_Value, false>* __p,
1409 std::size_t __bkt, std::size_t __bkt_count)
1410 : __node_iter_base(__p), _M_bucket(__bkt), _M_bucket_count(__bkt_count)
1413 ~_Local_iterator_base()
1415 if (_M_bucket_count !=
size_t(-1))
1419 _Local_iterator_base(
const _Local_iterator_base& __iter)
1420 : __node_iter_base(__iter._M_cur), _M_bucket(__iter._M_bucket)
1421 , _M_bucket_count(__iter._M_bucket_count)
1423 if (_M_bucket_count !=
size_t(-1))
1424 _M_init(*__iter._M_h());
1427 _Local_iterator_base&
1428 operator=(
const _Local_iterator_base& __iter)
1430 if (_M_bucket_count != -1)
1432 this->_M_cur = __iter._M_cur;
1433 _M_bucket = __iter._M_bucket;
1434 _M_bucket_count = __iter._M_bucket_count;
1435 if (_M_bucket_count != -1)
1436 _M_init(*__iter._M_h());
1443 __node_iter_base::_M_incr();
1446 std::size_t __bkt = this->_M_h()->_M_bucket_index(*this->_M_cur,
1448 if (__bkt != _M_bucket)
1449 this->_M_cur =
nullptr;
1453 std::size_t _M_bucket;
1454 std::size_t _M_bucket_count;
1457 _M_init(
const __hash_code_base&
__base)
1458 { ::new(this->_M_h()) __hash_code_base(
__base); }
1461 _M_destroy() { this->_M_h()->~__hash_code_base(); }
1465 _M_get_bucket()
const {
return _M_bucket; }
1469 template<
typename _Key,
typename _Value,
typename _ExtractKey,
1470 typename _Hash,
typename _RangeHash,
typename _Unused,
1471 bool __constant_iterators,
bool __cache>
1472 struct _Local_iterator
1473 :
public _Local_iterator_base<_Key, _Value, _ExtractKey,
1474 _Hash, _RangeHash, _Unused, __cache>
1477 using __base_type = _Local_iterator_base<_Key, _Value, _ExtractKey,
1478 _Hash, _RangeHash, _Unused, __cache>;
1479 using __hash_code_base =
typename __base_type::__hash_code_base;
1482 using value_type = _Value;
1483 using pointer = __conditional_t<__constant_iterators,
1484 const value_type*, value_type*>;
1485 using reference = __conditional_t<__constant_iterators,
1486 const value_type&, value_type&>;
1487 using difference_type = ptrdiff_t;
1488 using iterator_category = forward_iterator_tag;
1490 _Local_iterator() =
default;
1492 _Local_iterator(
const __hash_code_base&
__base,
1493 _Hash_node<_Value, __cache>* __n,
1494 std::size_t __bkt, std::size_t __bkt_count)
1495 : __base_type(
__base, __n, __bkt, __bkt_count)
1500 {
return this->_M_cur->_M_v(); }
1504 {
return this->_M_cur->_M_valptr(); }
1516 _Local_iterator __tmp(*
this);
1523 template<
typename _Key,
typename _Value,
typename _ExtractKey,
1524 typename _Hash,
typename _RangeHash,
typename _Unused,
1525 bool __constant_iterators,
bool __cache>
1526 struct _Local_const_iterator
1527 :
public _Local_iterator_base<_Key, _Value, _ExtractKey,
1528 _Hash, _RangeHash, _Unused, __cache>
1531 using __base_type = _Local_iterator_base<_Key, _Value, _ExtractKey,
1532 _Hash, _RangeHash, _Unused, __cache>;
1533 using __hash_code_base =
typename __base_type::__hash_code_base;
1536 typedef _Value value_type;
1537 typedef const value_type* pointer;
1538 typedef const value_type& reference;
1539 typedef std::ptrdiff_t difference_type;
1542 _Local_const_iterator() =
default;
1544 _Local_const_iterator(
const __hash_code_base&
__base,
1545 _Hash_node<_Value, __cache>* __n,
1546 std::size_t __bkt, std::size_t __bkt_count)
1547 : __base_type(
__base, __n, __bkt, __bkt_count)
1550 _Local_const_iterator(
const _Local_iterator<_Key, _Value, _ExtractKey,
1551 _Hash, _RangeHash, _Unused,
1552 __constant_iterators,
1559 {
return this->_M_cur->_M_v(); }
1563 {
return this->_M_cur->_M_valptr(); }
1565 _Local_const_iterator&
1572 _Local_const_iterator
1575 _Local_const_iterator __tmp(*
this);
1591 template<
typename _Key,
typename _Value,
typename _ExtractKey,
1592 typename _Equal,
typename _Hash,
typename _RangeHash,
1593 typename _Unused,
typename _Traits>
1594 struct _Hashtable_base
1595 :
public _Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash,
1596 _Unused, _Traits::__hash_cached::value>,
1597 private _Hashtable_ebo_helper<0, _Equal>
1600 typedef _Key key_type;
1601 typedef _Value value_type;
1602 typedef _Equal key_equal;
1603 typedef std::size_t size_type;
1604 typedef std::ptrdiff_t difference_type;
1606 using __traits_type = _Traits;
1607 using __hash_cached =
typename __traits_type::__hash_cached;
1609 using __hash_code_base = _Hash_code_base<_Key, _Value, _ExtractKey,
1610 _Hash, _RangeHash, _Unused,
1611 __hash_cached::value>;
1613 using __hash_code =
typename __hash_code_base::__hash_code;
1616 using _EqualEBO = _Hashtable_ebo_helper<0, _Equal>;
1619 _S_equals(__hash_code,
const _Hash_node_code_cache<false>&)
1623 _S_node_equals(
const _Hash_node_code_cache<false>&,
1624 const _Hash_node_code_cache<false>&)
1628 _S_equals(__hash_code __c,
const _Hash_node_code_cache<true>& __n)
1629 {
return __c == __n._M_hash_code; }
1632 _S_node_equals(
const _Hash_node_code_cache<true>& __lhn,
1633 const _Hash_node_code_cache<true>& __rhn)
1634 {
return __lhn._M_hash_code == __rhn._M_hash_code; }
1637 _Hashtable_base() =
default;
1639 _Hashtable_base(
const _Hash& __hash,
const _Equal& __eq)
1640 : __hash_code_base(__hash), _EqualEBO(__eq)
1644 _M_equals(
const _Key& __k, __hash_code __c,
1645 const _Hash_node_value<_Value, __hash_cached::value>& __n)
const
1647 static_assert(__is_invocable<const _Equal&, const _Key&, const _Key&>{},
1648 "key equality predicate must be invocable with two arguments of "
1650 return _S_equals(__c, __n) && _M_eq()(__k, _ExtractKey{}(__n._M_v()));
1653 template<
typename _Kt>
1655 _M_equals_tr(
const _Kt& __k, __hash_code __c,
1656 const _Hash_node_value<_Value,
1657 __hash_cached::value>& __n)
const
1660 __is_invocable<const _Equal&, const _Kt&, const _Key&>{},
1661 "key equality predicate must be invocable with two arguments of "
1663 return _S_equals(__c, __n) && _M_eq()(__k, _ExtractKey{}(__n._M_v()));
1668 const _Hash_node_value<_Value, __hash_cached::value>& __lhn,
1669 const _Hash_node_value<_Value, __hash_cached::value>& __rhn)
const
1671 return _S_node_equals(__lhn, __rhn)
1672 && _M_eq()(_ExtractKey{}(__lhn._M_v()), _ExtractKey{}(__rhn._M_v()));
1676 _M_swap(_Hashtable_base& __x)
1678 __hash_code_base::_M_swap(__x);
1679 std::swap(_EqualEBO::_M_get(), __x._EqualEBO::_M_get());
1683 _M_eq()
const {
return _EqualEBO::_M_cget(); }
1694 template<
typename _Key,
typename _Value,
typename _Alloc,
1695 typename _ExtractKey,
typename _Equal,
1696 typename _Hash,
typename _RangeHash,
typename _Unused,
1697 typename _RehashPolicy,
typename _Traits,
1698 bool _Unique_keys = _Traits::__unique_keys::value>
1702 template<
typename _Key,
typename _Value,
typename _Alloc,
1703 typename _ExtractKey,
typename _Equal,
1704 typename _Hash,
typename _RangeHash,
typename _Unused,
1705 typename _RehashPolicy,
typename _Traits>
1706 struct _Equality<_Key, _Value, _Alloc, _ExtractKey, _Equal,
1707 _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, true>
1709 using __hashtable = _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
1710 _Hash, _RangeHash, _Unused,
1711 _RehashPolicy, _Traits>;
1714 _M_equal(
const __hashtable&)
const;
1717 template<
typename _Key,
typename _Value,
typename _Alloc,
1718 typename _ExtractKey,
typename _Equal,
1719 typename _Hash,
typename _RangeHash,
typename _Unused,
1720 typename _RehashPolicy,
typename _Traits>
1722 _Equality<_Key, _Value, _Alloc, _ExtractKey, _Equal,
1723 _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits,
true>::
1724 _M_equal(
const __hashtable& __other)
const
1726 using __node_type =
typename __hashtable::__node_type;
1727 const __hashtable* __this =
static_cast<const __hashtable*
>(
this);
1728 if (__this->size() != __other.size())
1731 for (
auto __itx = __this->begin(); __itx != __this->end(); ++__itx)
1733 std::size_t __ybkt = __other._M_bucket_index(*__itx._M_cur);
1734 auto __prev_n = __other._M_buckets[__ybkt];
1738 for (__node_type* __n =
static_cast<__node_type*
>(__prev_n->_M_nxt);;
1739 __n = __n->_M_next())
1741 if (__n->_M_v() == *__itx)
1745 || __other._M_bucket_index(*__n->_M_next()) != __ybkt)
1754 template<
typename _Key,
typename _Value,
typename _Alloc,
1755 typename _ExtractKey,
typename _Equal,
1756 typename _Hash,
typename _RangeHash,
typename _Unused,
1757 typename _RehashPolicy,
typename _Traits>
1758 struct _Equality<_Key, _Value, _Alloc, _ExtractKey, _Equal,
1759 _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, false>
1761 using __hashtable = _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
1762 _Hash, _RangeHash, _Unused,
1763 _RehashPolicy, _Traits>;
1766 _M_equal(
const __hashtable&)
const;
1769 template<
typename _Key,
typename _Value,
typename _Alloc,
1770 typename _ExtractKey,
typename _Equal,
1771 typename _Hash,
typename _RangeHash,
typename _Unused,
1772 typename _RehashPolicy,
typename _Traits>
1774 _Equality<_Key, _Value, _Alloc, _ExtractKey, _Equal,
1775 _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits,
false>::
1776 _M_equal(
const __hashtable& __other)
const
1778 using __node_type =
typename __hashtable::__node_type;
1779 const __hashtable* __this =
static_cast<const __hashtable*
>(
this);
1780 if (__this->size() != __other.size())
1783 for (
auto __itx = __this->begin(); __itx != __this->end();)
1785 std::size_t __x_count = 1;
1786 auto __itx_end = __itx;
1787 for (++__itx_end; __itx_end != __this->end()
1788 && __this->key_eq()(_ExtractKey{}(*__itx),
1789 _ExtractKey{}(*__itx_end));
1793 std::size_t __ybkt = __other._M_bucket_index(*__itx._M_cur);
1794 auto __y_prev_n = __other._M_buckets[__ybkt];
1798 __node_type* __y_n =
static_cast<__node_type*
>(__y_prev_n->_M_nxt);
1801 if (__this->key_eq()(_ExtractKey{}(__y_n->_M_v()),
1802 _ExtractKey{}(*__itx)))
1805 auto __y_ref_n = __y_n;
1806 for (__y_n = __y_n->_M_next(); __y_n; __y_n = __y_n->_M_next())
1807 if (!__other._M_node_equals(*__y_ref_n, *__y_n))
1810 if (!__y_n || __other._M_bucket_index(*__y_n) != __ybkt)
1814 typename __hashtable::const_iterator __ity(__y_n);
1815 for (
auto __ity_end = __ity; __ity_end != __other.end(); ++__ity_end)
1816 if (--__x_count == 0)
1822 if (!std::is_permutation(__itx, __itx_end, __ity))
1834 template<
typename _NodeAlloc>
1835 struct _Hashtable_alloc :
private _Hashtable_ebo_helper<0, _NodeAlloc>
1838 using __ebo_node_alloc = _Hashtable_ebo_helper<0, _NodeAlloc>;
1841 struct __get_value_type;
1842 template<
typename _Val,
bool _Cache_hash_code>
1843 struct __get_value_type<_Hash_node<_Val, _Cache_hash_code>>
1844 {
using type = _Val; };
1847 using __node_type =
typename _NodeAlloc::value_type;
1848 using __node_alloc_type = _NodeAlloc;
1852 using __value_alloc_traits =
typename __node_alloc_traits::template
1853 rebind_traits<typename __get_value_type<__node_type>::type>;
1855 using __node_ptr = __node_type*;
1856 using __node_base = _Hash_node_base;
1857 using __node_base_ptr = __node_base*;
1858 using __buckets_alloc_type =
1859 __alloc_rebind<__node_alloc_type, __node_base_ptr>;
1861 using __buckets_ptr = __node_base_ptr*;
1863 _Hashtable_alloc() =
default;
1864 _Hashtable_alloc(
const _Hashtable_alloc&) =
default;
1865 _Hashtable_alloc(_Hashtable_alloc&&) =
default;
1867 template<
typename _Alloc>
1868 _Hashtable_alloc(_Alloc&& __a)
1869 : __ebo_node_alloc(
std::
forward<_Alloc>(__a))
1874 {
return __ebo_node_alloc::_M_get(); }
1876 const __node_alloc_type&
1877 _M_node_allocator()
const
1878 {
return __ebo_node_alloc::_M_cget(); }
1881 template<
typename... _Args>
1883 _M_allocate_node(_Args&&... __args);
1887 _M_deallocate_node(__node_ptr __n);
1891 _M_deallocate_node_ptr(__node_ptr __n);
1896 _M_deallocate_nodes(__node_ptr __n);
1899 _M_allocate_buckets(std::size_t __bkt_count);
1902 _M_deallocate_buckets(__buckets_ptr, std::size_t __bkt_count);
1907 template<
typename _NodeAlloc>
1908 template<
typename... _Args>
1910 _Hashtable_alloc<_NodeAlloc>::_M_allocate_node(_Args&&... __args)
1913 auto __nptr = __node_alloc_traits::allocate(_M_node_allocator(), 1);
1914 __node_ptr __n = std::__to_address(__nptr);
1917 ::new ((
void*)__n) __node_type;
1918 __node_alloc_traits::construct(_M_node_allocator(),
1920 std::forward<_Args>(__args)...);
1925 __node_alloc_traits::deallocate(_M_node_allocator(), __nptr, 1);
1926 __throw_exception_again;
1930 template<
typename _NodeAlloc>
1932 _Hashtable_alloc<_NodeAlloc>::_M_deallocate_node(__node_ptr __n)
1934 __node_alloc_traits::destroy(_M_node_allocator(), __n->_M_valptr());
1935 _M_deallocate_node_ptr(__n);
1938 template<
typename _NodeAlloc>
1940 _Hashtable_alloc<_NodeAlloc>::_M_deallocate_node_ptr(__node_ptr __n)
1942 typedef typename __node_alloc_traits::pointer _Ptr;
1944 __n->~__node_type();
1945 __node_alloc_traits::deallocate(_M_node_allocator(), __ptr, 1);
1948 template<
typename _NodeAlloc>
1950 _Hashtable_alloc<_NodeAlloc>::_M_deallocate_nodes(__node_ptr __n)
1954 __node_ptr __tmp = __n;
1955 __n = __n->_M_next();
1956 _M_deallocate_node(__tmp);
1960 template<
typename _NodeAlloc>
1962 _Hashtable_alloc<_NodeAlloc>::_M_allocate_buckets(std::size_t __bkt_count)
1965 __buckets_alloc_type __alloc(_M_node_allocator());
1967 auto __ptr = __buckets_alloc_traits::allocate(__alloc, __bkt_count);
1968 __buckets_ptr __p = std::__to_address(__ptr);
1969 __builtin_memset(__p, 0, __bkt_count *
sizeof(__node_base_ptr));
1973 template<
typename _NodeAlloc>
1975 _Hashtable_alloc<_NodeAlloc>::
1976 _M_deallocate_buckets(__buckets_ptr __bkts,
1977 std::size_t __bkt_count)
1979 typedef typename __buckets_alloc_traits::pointer _Ptr;
1981 __buckets_alloc_type __alloc(_M_node_allocator());
1982 __buckets_alloc_traits::deallocate(__alloc, __ptr, __bkt_count);
1988 _GLIBCXX_END_NAMESPACE_VERSION
constexpr complex< _Tp > operator*(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x times y.
integral_constant< bool, true > true_type
The type used as a compile-time boolean with true value.
integral_constant< bool, false > false_type
The type used as a compile-time boolean with false value.
constexpr piecewise_construct_t piecewise_construct
Tag for piecewise construction of std::pair objects.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr tuple< _Elements &&... > forward_as_tuple(_Elements &&... __args) noexcept
std::forward_as_tuple
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
constexpr iterator_traits< _Iter >::iterator_category __iterator_category(const _Iter &)
ISO C++ entities toplevel namespace is std.
constexpr iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
__numeric_traits_integer< _Tp > __int_traits
Convenience alias for __numeric_traits<integer-type>.
constexpr _Iterator __base(_Iterator __it)
Primary class template, tuple.
Define a member typedef type only if a boolean constant is true.
Uniform interface to all allocator types.
Traits class for iterators.
Uniform interface to all pointer-like types.
Struct holding two objects of arbitrary type.
Forward iterators support a superset of input iterator operations.
Uniform interface to C++98 and C++11 allocators.