34#pragma GCC system_header
36#if __cplusplus >= 201703L
37# define __cpp_lib_node_extract 201606
43namespace std _GLIBCXX_VISIBILITY(default)
45_GLIBCXX_BEGIN_NAMESPACE_VERSION
63 template<
typename _Val,
typename _NodeAlloc>
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();
177 union _Optional_alloc
179 _Optional_alloc() { }
180 ~_Optional_alloc() { }
182 _Optional_alloc(_Optional_alloc&&) =
delete;
183 _Optional_alloc& operator=(_Optional_alloc&&) =
delete;
185 _Optional_alloc(
const _NodeAlloc& __alloc) noexcept
191 operator=(_NodeAlloc&& __alloc)
noexcept
194 if constexpr (_ATr::propagate_on_container_move_assignment::value)
196 else if constexpr (!_AllocTraits::is_always_equal::value)
197 __glibcxx_assert(_M_alloc == __alloc);
202 swap(_Optional_alloc& __other)
noexcept
205 if constexpr (_AllocTraits::propagate_on_container_swap::value)
206 swap(_M_alloc, __other._M_alloc);
207 else if constexpr (!_AllocTraits::is_always_equal::value)
208 __glibcxx_assert(_M_alloc == __other._M_alloc);
212 _NodeAlloc& operator*()
noexcept {
return _M_alloc; }
215 _NodeAlloc release()
noexcept
218 _M_alloc.~_NodeAlloc();
224 [[__no_unique_address__]] _Empty _M_empty;
225 [[__no_unique_address__]] _NodeAlloc _M_alloc;
228 [[__no_unique_address__]] _Optional_alloc _M_alloc;
230 template<
typename _Key2,
typename _Value2,
typename _KeyOfValue,
231 typename _Compare,
typename _ValueAlloc>
232 friend class _Rb_tree;
238 template<
typename _Key,
typename _Value,
typename _NodeAlloc>
249 using key_type = _Key;
250 using mapped_type =
typename _Value::second_type;
255 __glibcxx_assert(!this->empty());
260 mapped()
const noexcept
262 __glibcxx_assert(!this->empty());
271 swap(_M_pkey, __nh._M_pkey);
272 swap(_M_pmapped, __nh._M_pmapped);
277 noexcept(
noexcept(__x.swap(__y)))
284 const _NodeAlloc& __alloc)
289 auto& __key =
const_cast<_Key&
>(__ptr->_M_valptr()->first);
290 _M_pkey = _S_pointer_to(__key);
291 _M_pmapped = _S_pointer_to(__ptr->_M_valptr()->second);
296 _M_pmapped =
nullptr;
300 template<
typename _Tp>
305 __pointer<_Key> _M_pkey =
nullptr;
306 __pointer<typename _Value::second_type> _M_pmapped =
nullptr;
308 template<
typename _Tp>
310 _S_pointer_to(_Tp& __obj)
314 _M_key()
const noexcept {
return key(); }
316 template<
typename _Key2,
typename _Value2,
typename _KeyOfValue,
317 typename _Compare,
typename _ValueAlloc>
318 friend class _Rb_tree;
320 template<
typename _Key2,
typename _Value2,
typename _ValueAlloc,
321 typename _ExtractKey,
typename _Equal,
322 typename _Hash,
typename _RangeHash,
typename _Unused,
323 typename _RehashPolicy,
typename _Traits>
324 friend class _Hashtable;
328 template<
typename _Value,
typename _NodeAlloc>
340 using value_type = _Value;
343 value()
const noexcept
345 __glibcxx_assert(!this->empty());
346 return *this->_M_ptr->_M_valptr();
351 { this->_M_swap(__nh); }
355 noexcept(
noexcept(__x.swap(__y)))
362 const _NodeAlloc& __alloc)
366 _M_key()
const noexcept {
return value(); }
368 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
369 typename _Compare,
typename _Alloc>
370 friend class _Rb_tree;
372 template<
typename _Key2,
typename _Value2,
typename _ValueAlloc,
373 typename _ExtractKey,
typename _Equal,
374 typename _Hash,
typename _RangeHash,
typename _Unused,
375 typename _RehashPolicy,
typename _Traits>
376 friend class _Hashtable;
380 template<
typename _Iterator,
typename _NodeHandle>
383 _Iterator position = _Iterator();
384 bool inserted =
false;
390_GLIBCXX_END_NAMESPACE_VERSION
typename remove_reference< _Tp >::type remove_reference_t
Alias template for remove_reference.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
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 deallocate(_Alloc &__a, pointer __p, size_type __n)
Deallocate memory.
static constexpr void destroy(_Alloc &__a, _Tp *__p) noexcept(noexcept(_S_destroy(__a, __p, 0)))
Destroy an object of type _Tp.
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.