32 #define _NODE_HANDLE 1
34 #ifdef _GLIBCXX_SYSHDR
35 #pragma GCC system_header
40 #ifdef __glibcxx_node_extract
46 namespace std _GLIBCXX_VISIBILITY(default)
48 _GLIBCXX_BEGIN_NAMESPACE_VERSION
66 template<
typename _Val,
typename _NodeAlloc>
72 using allocator_type = __alloc_rebind<_NodeAlloc, _Val>;
75 get_allocator()
const noexcept
77 __glibcxx_assert(!this->empty());
78 return allocator_type(_M_alloc._M_alloc);
81 explicit operator bool()
const noexcept {
return _M_ptr !=
nullptr; }
83 [[nodiscard]]
bool empty()
const noexcept {
return _M_ptr ==
nullptr; }
110 else if (__nh.empty())
118 _M_alloc = __nh._M_alloc.release();
119 _M_ptr = __nh._M_ptr;
120 __nh._M_ptr =
nullptr;
126 const _NodeAlloc& __alloc)
127 : _M_ptr(__ptr), _M_alloc(__alloc)
129 __glibcxx_assert(__ptr !=
nullptr);
140 else if (__nh.empty())
145 swap(_M_ptr, __nh._M_ptr);
146 _M_alloc.swap(__nh._M_alloc);
158 _M_ptr = __nh._M_ptr;
159 __nh._M_ptr =
nullptr;
168 _NodeAlloc __alloc = _M_alloc.release();
190 union _Optional_alloc
192 _Optional_alloc() { }
193 ~_Optional_alloc() { }
195 _Optional_alloc(_Optional_alloc&&) =
delete;
196 _Optional_alloc& operator=(_Optional_alloc&&) =
delete;
198 _Optional_alloc(
const _NodeAlloc& __alloc) noexcept
204 operator=(_NodeAlloc&& __alloc) noexcept
207 if constexpr (_ATr::propagate_on_container_move_assignment::value)
209 else if constexpr (!_AllocTraits::is_always_equal::value)
210 __glibcxx_assert(_M_alloc == __alloc);
215 swap(_Optional_alloc& __other) noexcept
218 if constexpr (_AllocTraits::propagate_on_container_swap::value)
219 swap(_M_alloc, __other._M_alloc);
220 else if constexpr (!_AllocTraits::is_always_equal::value)
221 __glibcxx_assert(_M_alloc == __other._M_alloc);
225 _NodeAlloc&
operator*() noexcept {
return _M_alloc; }
228 _NodeAlloc release() noexcept
231 _M_alloc.~_NodeAlloc();
235 [[__no_unique_address__]] _NodeAlloc _M_alloc;
238 [[__no_unique_address__]] _Optional_alloc _M_alloc;
240 template<
typename _Key2,
typename _Value2,
typename _KeyOfValue,
241 typename _Compare,
typename _ValueAlloc>
242 friend class _Rb_tree;
244 template<
typename _Key2,
typename _Value2,
typename _ValueAlloc,
245 typename _ExtractKey,
typename _Equal,
246 typename _Hash,
typename _RangeHash,
typename _Unused,
247 typename _RehashPolicy,
typename _Traits>
248 friend class _Hashtable;
254 template<
typename _Key,
typename _Value,
typename _NodeAlloc>
265 using key_type = _Key;
266 using mapped_type =
typename _Value::second_type;
271 __glibcxx_assert(!this->empty());
276 mapped()
const noexcept
278 __glibcxx_assert(!this->empty());
287 swap(_M_pkey, __nh._M_pkey);
288 swap(_M_pmapped, __nh._M_pmapped);
293 noexcept(noexcept(__x.swap(__y)))
300 const _NodeAlloc& __alloc)
305 auto& __key =
const_cast<_Key&
>(__ptr->_M_valptr()->first);
306 _M_pkey = _S_pointer_to(__key);
307 _M_pmapped = _S_pointer_to(__ptr->_M_valptr()->second);
312 _M_pmapped =
nullptr;
316 template<
typename _Tp>
321 __pointer<_Key> _M_pkey =
nullptr;
322 __pointer<typename _Value::second_type> _M_pmapped =
nullptr;
324 template<
typename _Tp>
326 _S_pointer_to(_Tp& __obj)
330 _M_key()
const noexcept {
return key(); }
332 template<
typename _Key2,
typename _Value2,
typename _KeyOfValue,
333 typename _Compare,
typename _ValueAlloc>
334 friend class _Rb_tree;
336 template<
typename _Key2,
typename _Value2,
typename _ValueAlloc,
337 typename _ExtractKey,
typename _Equal,
338 typename _Hash,
typename _RangeHash,
typename _Unused,
339 typename _RehashPolicy,
typename _Traits>
340 friend class _Hashtable;
344 template<
typename _Value,
typename _NodeAlloc>
356 using value_type = _Value;
359 value()
const noexcept
361 __glibcxx_assert(!this->empty());
362 return *this->_M_ptr->_M_valptr();
367 { this->_M_swap(__nh); }
371 noexcept(noexcept(__x.swap(__y)))
378 const _NodeAlloc& __alloc)
382 _M_key()
const noexcept {
return value(); }
384 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
385 typename _Compare,
typename _Alloc>
386 friend class _Rb_tree;
388 template<
typename _Key2,
typename _Value2,
typename _ValueAlloc,
389 typename _ExtractKey,
typename _Equal,
390 typename _Hash,
typename _RangeHash,
typename _Unused,
391 typename _RehashPolicy,
typename _Traits>
392 friend class _Hashtable;
396 template<
typename _Iterator,
typename _NodeHandle>
399 _Iterator position = _Iterator();
400 bool inserted =
false;
406 _GLIBCXX_END_NAMESPACE_VERSION
constexpr complex< _Tp > operator*(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x times y.
typename remove_reference< _Tp >::type remove_reference_t
Alias template for remove_reference.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
ISO C++ entities toplevel namespace is std.
typename pointer_traits< _Ptr >::template rebind< _Tp > __ptr_rebind
Convenience alias for rebinding pointers.
Uniform interface to all allocator types.
__detected_or_t< value_type *, __pointer, _Alloc > pointer
The allocator's pointer type.
static constexpr void destroy(_Alloc &__a, _Tp *__p) noexcept(_S_nothrow_destroy< _Tp >())
Destroy an object of type _Tp.
static constexpr void deallocate(_Alloc &__a, pointer __p, size_type __n)
Deallocate memory.
Base class for node handle types of maps and sets.
Node handle type for maps.
Return type of insert(node_handle&&) on unique maps/sets.
Uniform interface to all pointer-like types.