Files
2025-10-25 03:02:53 +03:00

68 lines
4.9 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[container.node.overview]
# 23 Containers library [[containers]](./#containers)
## 23.2 Requirements [[container.requirements]](container.requirements#container.node.overview)
### 23.2.5 Node handles [[container.node]](container.node#overview)
#### 23.2.5.1 Overview [container.node.overview]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2318)
A [*node handle*](#def:node_handle "23.2.5.1Overview[container.node.overview]") is an object that accepts ownership of a single element
from an associative container ([[associative.reqmts]](associative.reqmts "23.2.7Associative containers")) or an unordered
associative container ([[unord.req]](unord.req "23.2.8Unordered associative containers"))[.](#1.sentence-1)
It may be used to transfer that
ownership to another container with compatible nodes[.](#1.sentence-2)
Containers with
compatible nodes have the same node handle type[.](#1.sentence-3)
Elements may be transferred in
either direction between container types in the same row of
Table [75](#tab:container.node.compat "Table 75: Container types with compatible nodes")[.](#1.sentence-4)
Table [75](#tab:container.node.compat) — Container types with compatible nodes [[tab:container.node.compat]](./tab:container.node.compat)
| [🔗](#tab:container.node.compat-row-1)<br>map<K, T, C1, A> | map<K, T, C2, A> |
| --- | --- |
| [🔗](#tab:container.node.compat-row-2)<br>map<K, T, C1, A> | multimap<K, T, C2, A> |
| [🔗](#tab:container.node.compat-row-3)<br>set<K, C1, A> | set<K, C2, A> |
| [🔗](#tab:container.node.compat-row-4)<br>set<K, C1, A> | multiset<K, C2, A> |
| [🔗](#tab:container.node.compat-row-5)<br>unordered_map<K, T, H1, E1, A> | unordered_map<K, T, H2, E2, A> |
| [🔗](#tab:container.node.compat-row-6)<br>unordered_map<K, T, H1, E1, A> | unordered_multimap<K, T, H2, E2, A> |
| [🔗](#tab:container.node.compat-row-7)<br>unordered_set<K, H1, E1, A> | unordered_set<K, H2, E2, A> |
| [🔗](#tab:container.node.compat-row-8)<br>unordered_set<K, H1, E1, A> | unordered_multiset<K, H2, E2, A> |
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2347)
If a node handle is not empty, then it contains an allocator that is equal to
the allocator of the container when the element was extracted[.](#2.sentence-1)
If a node handle
is empty, it contains no allocator[.](#2.sentence-2)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2352)
Class *node-handle* is for exposition only[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2355)
If a user-defined specialization of pair exists forpair<const Key, T> or pair<Key, T>, where Key is the
container's key_type and T is the container'smapped_type, the behavior of operations involving node handles is
undefined[.](#4.sentence-1)
template<*unspecified*>class *node-handle* {public:// These type declarations are described in [[associative.reqmts]](associative.reqmts "23.2.7Associative containers") and [[unord.req]](unord.req "23.2.8Unordered associative containers").using value_type = *see below*; // not present for map containersusing key_type = *see below*; // not present for set containersusing mapped_type = *see below*; // not present for set containersusing allocator_type = *see below*;
private:using container_node_type = *unspecified*; // *exposition only*using ator_traits = allocator_traits<allocator_type>; // *exposition only*typename ator_traits::template rebind_traits<container_node_type>::pointer ptr_; // *exposition only* optional<allocator_type> alloc_; // *exposition only*public:// [[container.node.cons]](container.node.cons "23.2.5.2Constructors, copy, and assignment"), constructors, copy, and assignmentconstexpr *node-handle*() noexcept : ptr_(), alloc_() {}constexpr *node-handle*(*node-handle*&&) noexcept; constexpr *node-handle*& operator=(*node-handle*&&); // [[container.node.dtor]](container.node.dtor "23.2.5.3Destructor"), destructorconstexpr ~*node-handle*(); // [[container.node.observers]](container.node.observers "23.2.5.4Observers"), observersconstexpr value_type& value() const; // not present for map containers key_type& key() const; // not present for set containersconstexpr mapped_type& mapped() const; // not present for set containersconstexpr allocator_type get_allocator() const; constexpr explicit operator bool() const noexcept; constexpr bool empty() const noexcept; // [[container.node.modifiers]](container.node.modifiers "23.2.5.5Modifiers"), modifiersconstexpr void swap(*node-handle*&)noexcept(ator_traits::propagate_on_container_swap::value || ator_traits::is_always_equal::value); friend constexpr void swap(*node-handle*& x, *node-handle*& y) noexcept(noexcept(x.swap(y))) { x.swap(y); }};