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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### Node handles <a id="container.node">[[container.node]]</a>
|
| 2 |
+
|
| 3 |
+
#### `node_handle` overview <a id="container.node.overview">[[container.node.overview]]</a>
|
| 4 |
+
|
| 5 |
+
A *node handle* is an object that accepts ownership of a single element
|
| 6 |
+
from an associative container ([[associative.reqmts]]) or an unordered
|
| 7 |
+
associative container ([[unord.req]]). It may be used to transfer that
|
| 8 |
+
ownership to another container with compatible nodes. Containers with
|
| 9 |
+
compatible nodes have the same node handle type. Elements may be
|
| 10 |
+
transferred in either direction between container types in the same row
|
| 11 |
+
of Table [[tab:containers.node.compat]].
|
| 12 |
+
|
| 13 |
+
**Table: Container types with compatible nodes** <a id="tab:containers.node.compat">[tab:containers.node.compat]</a>
|
| 14 |
+
|
| 15 |
+
| | |
|
| 16 |
+
| -------------------------------- | ------------------------------------- |
|
| 17 |
+
| `map<K, T, C1, A>` | `map<K, T, C2, A>` |
|
| 18 |
+
| `map<K, T, C1, A>` | `multimap<K, T, C2, A>` |
|
| 19 |
+
| `set<K, C1, A>` | `set<K, C2, A>` |
|
| 20 |
+
| `set<K, C1, A>` | `multiset<K, C2, A>` |
|
| 21 |
+
| `unordered_map<K, T, H1, E1, A>` | `unordered_map<K, T, H2, E2, A>` |
|
| 22 |
+
| `unordered_map<K, T, H1, E1, A>` | `unordered_multimap<K, T, H2, E2, A>` |
|
| 23 |
+
| `unordered_set<K, H1, E1, A>` | `unordered_set<K, H2, E2, A>` |
|
| 24 |
+
| `unordered_set<K, H1, E1, A>` | `unordered_multiset<K, H2, E2, A>` |
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
If a node handle is not empty, then it contains an allocator that is
|
| 28 |
+
equal to the allocator of the container when the element was extracted.
|
| 29 |
+
If a node handle is empty, it contains no allocator.
|
| 30 |
+
|
| 31 |
+
Class `node_handle` is for exposition only. An implementation is
|
| 32 |
+
permitted to provide equivalent functionality without providing a class
|
| 33 |
+
with this name.
|
| 34 |
+
|
| 35 |
+
If a user-defined specialization of `pair` exists for
|
| 36 |
+
`pair<const Key, T>` or `pair<Key, T>`, where `Key` is the container’s
|
| 37 |
+
`key_type` and `T` is the container’s `mapped_type`, the behavior of
|
| 38 |
+
operations involving node handles is undefined.
|
| 39 |
+
|
| 40 |
+
``` cpp
|
| 41 |
+
template<unspecified>
|
| 42 |
+
class node_handle {
|
| 43 |
+
public:
|
| 44 |
+
// These type declarations are described in Tables [tab:containers.associative.requirements] and [tab:HashRequirements].
|
| 45 |
+
using value_type = see below; // not present for map containers
|
| 46 |
+
using key_type = see below; // not present for set containers
|
| 47 |
+
using mapped_type = see below; // not present for set containers
|
| 48 |
+
using allocator_type = see below;
|
| 49 |
+
|
| 50 |
+
private:
|
| 51 |
+
using container_node_type = unspecified;
|
| 52 |
+
using ator_traits = allocator_traits<allocator_type>;
|
| 53 |
+
|
| 54 |
+
typename ator_traits::rebind_traits<container_node_type>::pointer ptr_;
|
| 55 |
+
optional<allocator_type> alloc_;
|
| 56 |
+
|
| 57 |
+
public:
|
| 58 |
+
constexpr node_handle() noexcept : ptr_(), alloc_() {}
|
| 59 |
+
~node_handle();
|
| 60 |
+
node_handle(node_handle&&) noexcept;
|
| 61 |
+
node_handle& operator=(node_handle&&);
|
| 62 |
+
|
| 63 |
+
value_type& value() const; // not present for map containers
|
| 64 |
+
key_type& key() const; // not present for set containers
|
| 65 |
+
mapped_type& mapped() const; // not present for set containers
|
| 66 |
+
|
| 67 |
+
allocator_type get_allocator() const;
|
| 68 |
+
explicit operator bool() const noexcept;
|
| 69 |
+
bool empty() const noexcept;
|
| 70 |
+
|
| 71 |
+
void swap(node_handle&)
|
| 72 |
+
noexcept(ator_traits::propagate_on_container_swap::value ||
|
| 73 |
+
ator_traits::is_always_equal::value);
|
| 74 |
+
|
| 75 |
+
friend void swap(node_handle& x, node_handle& y) noexcept(noexcept(x.swap(y))) {
|
| 76 |
+
x.swap(y);
|
| 77 |
+
}
|
| 78 |
+
};
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
#### `node_handle` constructors, copy, and assignment <a id="container.node.cons">[[container.node.cons]]</a>
|
| 82 |
+
|
| 83 |
+
``` cpp
|
| 84 |
+
node_handle(node_handle&& nh) noexcept;
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
*Effects:* Constructs a *`node_handle`* object initializing `ptr_` with
|
| 88 |
+
`nh.ptr_`. Move constructs `alloc_` with `nh.alloc_`. Assigns `nullptr`
|
| 89 |
+
to `nh.ptr_` and assigns `nullopt` to `nh.alloc_`.
|
| 90 |
+
|
| 91 |
+
``` cpp
|
| 92 |
+
node_handle& operator=(node_handle&& nh);
|
| 93 |
+
```
|
| 94 |
+
|
| 95 |
+
*Requires:* Either `!alloc_`, or
|
| 96 |
+
`ator_traits::propagate_on_container_move_assignment` is `true`, or
|
| 97 |
+
`alloc_ == nh.alloc_`.
|
| 98 |
+
|
| 99 |
+
*Effects:*
|
| 100 |
+
|
| 101 |
+
- If `ptr_ != nullptr`, destroys the `value_type` subobject in the
|
| 102 |
+
`container_node_type` object pointed to by `ptr_` by calling
|
| 103 |
+
`ator_traits::destroy`, then deallocates `ptr_` by calling
|
| 104 |
+
`ator_traits::rebind_traits<container_node_type>::deallocate`.
|
| 105 |
+
- Assigns `nh.ptr_` to `ptr_`.
|
| 106 |
+
- If `!alloc` or `ator_traits::propagate_on_container_move_assignment`
|
| 107 |
+
is `true`, move assigns `nh.alloc_` to `alloc_`.
|
| 108 |
+
- Assigns `nullptr` to `nh.ptr_` and assigns `nullopt` to `nh.alloc_`.
|
| 109 |
+
|
| 110 |
+
*Returns:* `*this`.
|
| 111 |
+
|
| 112 |
+
*Throws:* Nothing.
|
| 113 |
+
|
| 114 |
+
#### `node_handle` destructor <a id="container.node.dtor">[[container.node.dtor]]</a>
|
| 115 |
+
|
| 116 |
+
``` cpp
|
| 117 |
+
~node_handle();
|
| 118 |
+
```
|
| 119 |
+
|
| 120 |
+
*Effects:* If `ptr_ != nullptr`, destroys the `value_type` subobject in
|
| 121 |
+
the `container_node_type` object pointed to by `ptr_` by calling
|
| 122 |
+
`ator_traits::destroy`, then deallocates `ptr_` by calling
|
| 123 |
+
`ator_traits::rebind_traits<container_node_type>::deallocate`.
|
| 124 |
+
|
| 125 |
+
#### `node_handle` observers <a id="container.node.observers">[[container.node.observers]]</a>
|
| 126 |
+
|
| 127 |
+
``` cpp
|
| 128 |
+
value_type& value() const;
|
| 129 |
+
```
|
| 130 |
+
|
| 131 |
+
*Requires:* `empty() == false`.
|
| 132 |
+
|
| 133 |
+
*Returns:* A reference to the `value_type` subobject in the
|
| 134 |
+
`container_node_type` object pointed to by `ptr_`.
|
| 135 |
+
|
| 136 |
+
*Throws:* Nothing.
|
| 137 |
+
|
| 138 |
+
``` cpp
|
| 139 |
+
key_type& key() const;
|
| 140 |
+
```
|
| 141 |
+
|
| 142 |
+
*Requires:* `empty() == false`.
|
| 143 |
+
|
| 144 |
+
*Returns:* A non-const reference to the `key_type` member of the
|
| 145 |
+
`value_type` subobject in the `container_node_type` object pointed to by
|
| 146 |
+
`ptr_`.
|
| 147 |
+
|
| 148 |
+
*Throws:* Nothing.
|
| 149 |
+
|
| 150 |
+
*Remarks:* Modifying the key through the returned reference is
|
| 151 |
+
permitted.
|
| 152 |
+
|
| 153 |
+
``` cpp
|
| 154 |
+
mapped_type& mapped() const;
|
| 155 |
+
```
|
| 156 |
+
|
| 157 |
+
*Requires:* `empty() == false`.
|
| 158 |
+
|
| 159 |
+
*Returns:* A reference to the `mapped_type` member of the `value_type`
|
| 160 |
+
subobject in the `container_node_type` object pointed to by `ptr_`.
|
| 161 |
+
|
| 162 |
+
*Throws:* Nothing.
|
| 163 |
+
|
| 164 |
+
``` cpp
|
| 165 |
+
allocator_type get_allocator() const;
|
| 166 |
+
```
|
| 167 |
+
|
| 168 |
+
*Requires:* `empty() == false`.
|
| 169 |
+
|
| 170 |
+
*Returns:* `*alloc_`.
|
| 171 |
+
|
| 172 |
+
*Throws:* Nothing.
|
| 173 |
+
|
| 174 |
+
``` cpp
|
| 175 |
+
explicit operator bool() const noexcept;
|
| 176 |
+
```
|
| 177 |
+
|
| 178 |
+
*Returns:* `ptr_ != nullptr`.
|
| 179 |
+
|
| 180 |
+
``` cpp
|
| 181 |
+
bool empty() const noexcept;
|
| 182 |
+
```
|
| 183 |
+
|
| 184 |
+
*Returns:* `ptr_ == nullptr`.
|
| 185 |
+
|
| 186 |
+
#### `node_handle` modifiers <a id="container.node.modifiers">[[container.node.modifiers]]</a>
|
| 187 |
+
|
| 188 |
+
``` cpp
|
| 189 |
+
void swap(node_handle& nh)
|
| 190 |
+
noexcept(ator_traits::propagate_on_container_swap::value ||
|
| 191 |
+
ator_traits::is_always_equal::value);
|
| 192 |
+
```
|
| 193 |
+
|
| 194 |
+
*Requires:* `!alloc_`, or `!nh.alloc_`, or
|
| 195 |
+
`ator_traits::propagate_on_container_swap` is `true`, or
|
| 196 |
+
`alloc_ == nh.alloc_`.
|
| 197 |
+
|
| 198 |
+
*Effects:* Calls `swap(ptr_, nh.ptr_)`. If `!alloc_`, or `!nh.alloc_`,
|
| 199 |
+
or `ator_traits::propagate_on_container_swap` is `true` calls
|
| 200 |
+
`swap(alloc_, nh.alloc_)`.
|
| 201 |
+
|