32 #define _NODE_HANDLE 1
34 #pragma GCC system_header
36 #if __cplusplus >= 201703L
37 # define __cpp_lib_node_extract 201606
43 namespace std _GLIBCXX_VISIBILITY(default)
45 _GLIBCXX_BEGIN_NAMESPACE_VERSION
48 template<
typename _Val,
typename _NodeAlloc>
54 using allocator_type = __alloc_rebind<_NodeAlloc, _Val>;
57 get_allocator()
const noexcept
59 __glibcxx_assert(!this->empty());
60 return allocator_type(_M_alloc._M_alloc);
63 explicit operator bool()
const noexcept {
return _M_ptr !=
nullptr; }
65 [[nodiscard]]
bool empty()
const noexcept {
return _M_ptr ==
nullptr; }
91 else if (__nh.empty())
99 _M_alloc = __nh._M_alloc.release();
100 _M_ptr = __nh._M_ptr;
101 __nh._M_ptr =
nullptr;
107 const _NodeAlloc& __alloc)
108 : _M_ptr(__ptr), _M_alloc(__alloc)
110 __glibcxx_assert(__ptr !=
nullptr);
121 else if (__nh.empty())
126 swap(_M_ptr, __nh._M_ptr);
127 _M_alloc.swap(__nh._M_alloc);
139 _M_ptr = __nh._M_ptr;
140 __nh._M_ptr =
nullptr;
149 _NodeAlloc __alloc = _M_alloc.release();
161 union _Optional_alloc
163 _Optional_alloc() { }
164 ~_Optional_alloc() { }
166 _Optional_alloc(_Optional_alloc&&) =
delete;
167 _Optional_alloc&
operator=(_Optional_alloc&&) =
delete;
169 _Optional_alloc(
const _NodeAlloc& __alloc) noexcept
178 if constexpr (_ATr::propagate_on_container_move_assignment::value)
180 else if constexpr (!_AllocTraits::is_always_equal::value)
181 __glibcxx_assert(_M_alloc == __alloc);
186 swap(_Optional_alloc& __other) noexcept
189 if constexpr (_AllocTraits::propagate_on_container_swap::value)
190 swap(_M_alloc, __other._M_alloc);
191 else if constexpr (!_AllocTraits::is_always_equal::value)
192 __glibcxx_assert(_M_alloc == __other._M_alloc);
196 _NodeAlloc&
operator*() noexcept {
return _M_alloc; }
202 _M_alloc.~_NodeAlloc();
208 [[__no_unique_address__]] _Empty _M_empty;
209 [[__no_unique_address__]] _NodeAlloc _M_alloc;
212 [[__no_unique_address__]] _Optional_alloc _M_alloc;
214 template<
typename _Key2,
typename _Value2,
typename _KeyOfValue,
215 typename _Compare,
typename _ValueAlloc>
216 friend class _Rb_tree;
220 template<
typename _Key,
typename _Value,
typename _NodeAlloc>
231 using key_type = _Key;
232 using mapped_type =
typename _Value::second_type;
237 __glibcxx_assert(!this->empty());
242 mapped()
const noexcept
244 __glibcxx_assert(!this->empty());
253 swap(_M_pkey, __nh._M_pkey);
254 swap(_M_pmapped, __nh._M_pmapped);
259 noexcept(noexcept(__x.swap(__y)))
266 const _NodeAlloc& __alloc)
271 auto& __key =
const_cast<_Key&
>(__ptr->_M_valptr()->first);
272 _M_pkey = _S_pointer_to(__key);
273 _M_pmapped = _S_pointer_to(__ptr->_M_valptr()->second);
278 _M_pmapped =
nullptr;
282 template<
typename _Tp>
287 __pointer<_Key> _M_pkey =
nullptr;
288 __pointer<typename _Value::second_type> _M_pmapped =
nullptr;
290 template<
typename _Tp>
292 _S_pointer_to(_Tp& __obj)
296 _M_key()
const noexcept {
return key(); }
298 template<
typename _Key2,
typename _Value2,
typename _KeyOfValue,
299 typename _Compare,
typename _ValueAlloc>
300 friend class _Rb_tree;
302 template<
typename _Key2,
typename _Value2,
typename _ValueAlloc,
303 typename _ExtractKey,
typename _Equal,
304 typename _Hash,
typename _RangeHash,
typename _Unused,
305 typename _RehashPolicy,
typename _Traits>
310 template<
typename _Value,
typename _NodeAlloc>
322 using value_type = _Value;
325 value()
const noexcept
327 __glibcxx_assert(!this->empty());
328 return *this->_M_ptr->_M_valptr();
333 { this->_M_swap(__nh); }
337 noexcept(noexcept(__x.swap(__y)))
344 const _NodeAlloc& __alloc)
348 _M_key()
const noexcept {
return value(); }
350 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
351 typename _Compare,
typename _Alloc>
352 friend class _Rb_tree;
354 template<
typename _Key2,
typename _Value2,
typename _ValueAlloc,
355 typename _ExtractKey,
typename _Equal,
356 typename _Hash,
typename _RangeHash,
typename _Unused,
357 typename _RehashPolicy,
typename _Traits>
362 template<
typename _Iterator,
typename _NodeHandle>
365 _Iterator position = _Iterator();
366 bool inserted =
false;
370 _GLIBCXX_END_NAMESPACE_VERSION
auto_ptr & operator=(auto_ptr &__a)
auto_ptr assignment operator.
element_type * release()
Bypassing the smart pointer.
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.
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
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.