69 using allocator_type = __alloc_rebind<_NodeAlloc, _Val>;
72 get_allocator()
const noexcept
74 __glibcxx_assert(!this->empty());
75 return allocator_type(_M_alloc._M_alloc);
78 explicit operator bool()
const noexcept {
return _M_ptr !=
nullptr; }
80 [[nodiscard]]
bool empty()
const noexcept {
return _M_ptr ==
nullptr; }
107 else if (__nh.empty())
115 _M_alloc = __nh._M_alloc.release();
116 _M_ptr = __nh._M_ptr;
117 __nh._M_ptr =
nullptr;
123 const _NodeAlloc& __alloc)
124 : _M_ptr(__ptr), _M_alloc(__alloc)
126 __glibcxx_assert(__ptr !=
nullptr);
137 else if (__nh.empty())
142 swap(_M_ptr, __nh._M_ptr);
143 _M_alloc.swap(__nh._M_alloc);
155 _M_ptr = __nh._M_ptr;
156 __nh._M_ptr =
nullptr;
165 _NodeAlloc __alloc = _M_alloc.release();
187 union _Optional_alloc
189 _Optional_alloc() { }
190 ~_Optional_alloc() { }
192 _Optional_alloc(_Optional_alloc&&) =
delete;
193 _Optional_alloc& operator=(_Optional_alloc&&) =
delete;
195 _Optional_alloc(
const _NodeAlloc& __alloc) noexcept
201 operator=(_NodeAlloc&& __alloc)
noexcept
203 using _ATr = _AllocTraits;
204 if constexpr (_ATr::propagate_on_container_move_assignment::value)
206 else if constexpr (!_AllocTraits::is_always_equal::value)
207 __glibcxx_assert(_M_alloc == __alloc);
212 swap(_Optional_alloc& __other)
noexcept
215 if constexpr (_AllocTraits::propagate_on_container_swap::value)
216 swap(_M_alloc, __other._M_alloc);
217 else if constexpr (!_AllocTraits::is_always_equal::value)
218 __glibcxx_assert(_M_alloc == __other._M_alloc);
222 _NodeAlloc&
operator*()
noexcept {
return _M_alloc; }
225 _NodeAlloc release()
noexcept
228 _M_alloc.~_NodeAlloc();
232 [[__no_unique_address__]] _NodeAlloc _M_alloc;
235 [[__no_unique_address__]] _Optional_alloc _M_alloc;
237 template<
typename _Key2,
typename _Value2,
typename _KeyOfValue,
238 typename _Compare,
typename _ValueAlloc>
239 friend class _Rb_tree;
241 template<
typename _Key2,
typename _Value2,
typename _ValueAlloc,
242 typename _ExtractKey,
typename _Equal,
243 typename _Hash,
typename _RangeHash,
typename _Unused,
244 typename _RehashPolicy,
typename _Traits>
245 friend class _Hashtable;
255 constexpr _Node_handle()
noexcept =
default;
256 ~_Node_handle() =
default;
257 _Node_handle(_Node_handle&&)
noexcept =
default;
260 operator=(_Node_handle&&)
noexcept =
default;
262 using key_type = _Key;
263 using mapped_type =
typename _Value::second_type;
268 __glibcxx_assert(!this->empty());
273 mapped()
const noexcept
275 __glibcxx_assert(!this->empty());
280 swap(_Node_handle& __nh)
noexcept
284 swap(_M_pkey, __nh._M_pkey);
285 swap(_M_pmapped, __nh._M_pmapped);
289 swap(_Node_handle& __x, _Node_handle& __y)
290 noexcept(
noexcept(__x.swap(__y)))
297 const _NodeAlloc& __alloc)
302 auto& __key =
const_cast<_Key&
>(__ptr->_M_valptr()->first);
303 _M_pkey = _S_pointer_to(__key);
304 _M_pmapped = _S_pointer_to(__ptr->_M_valptr()->second);
309 _M_pmapped =
nullptr;
313 template<
typename _Tp>
318 __pointer<_Key> _M_pkey =
nullptr;
319 __pointer<typename _Value::second_type> _M_pmapped =
nullptr;
321 template<
typename _Tp>
323 _S_pointer_to(_Tp& __obj)
327 _M_key()
const noexcept {
return key(); }
329 template<
typename _Key2,
typename _Value2,
typename _KeyOfValue,
330 typename _Compare,
typename _ValueAlloc>
331 friend class _Rb_tree;
333 template<
typename _Key2,
typename _Value2,
typename _ValueAlloc,
334 typename _ExtractKey,
typename _Equal,
335 typename _Hash,
typename _RangeHash,
typename _Unused,
336 typename _RehashPolicy,
typename _Traits>
337 friend class _Hashtable;
342 class _Node_handle<_Value, _Value, _NodeAlloc>
346 constexpr _Node_handle()
noexcept =
default;
347 ~_Node_handle() =
default;
348 _Node_handle(_Node_handle&&)
noexcept =
default;
351 operator=(_Node_handle&&)
noexcept =
default;
353 using value_type = _Value;
356 value()
const noexcept
358 __glibcxx_assert(!this->empty());
359 return *this->_M_ptr->_M_valptr();
363 swap(_Node_handle& __nh)
noexcept
364 { this->_M_swap(__nh); }
367 swap(_Node_handle& __x, _Node_handle& __y)
368 noexcept(
noexcept(__x.swap(__y)))
375 const _NodeAlloc& __alloc)
379 _M_key()
const noexcept {
return value(); }
381 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
382 typename _Compare,
typename _Alloc>
383 friend class _Rb_tree;
385 template<
typename _Key2,
typename _Value2,
typename _ValueAlloc,
386 typename _ExtractKey,
typename _Equal,
387 typename _Hash,
typename _RangeHash,
typename _Unused,
388 typename _RehashPolicy,
typename _Traits>
389 friend class _Hashtable;