tmp/tmpdrkp9k_4/{from.md → to.md}
RENAMED
|
@@ -1,18 +1,18 @@
|
|
| 1 |
### Node handles <a id="container.node">[[container.node]]</a>
|
| 2 |
|
| 3 |
-
####
|
| 4 |
|
| 5 |
A *node handle* is an object that accepts ownership of a single element
|
| 6 |
-
from an associative container
|
| 7 |
-
associative container
|
| 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
|
| 12 |
|
| 13 |
-
**Table: Container types with compatible nodes** <a id="
|
| 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>` |
|
|
@@ -26,122 +26,126 @@ of Table [[tab:containers.node.compat]].
|
|
| 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 `
|
| 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 |
-
|
| 43 |
public:
|
| 44 |
-
|
| 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 |
-
|
| 55 |
optional<allocator_type> alloc_;
|
| 56 |
|
| 57 |
public:
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 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 |
-
|
| 70 |
|
| 71 |
-
|
|
|
|
| 72 |
noexcept(ator_traits::propagate_on_container_swap::value ||
|
| 73 |
ator_traits::is_always_equal::value);
|
| 74 |
|
| 75 |
-
|
| 76 |
x.swap(y);
|
| 77 |
}
|
| 78 |
};
|
| 79 |
```
|
| 80 |
|
| 81 |
-
####
|
| 82 |
|
| 83 |
``` cpp
|
| 84 |
-
|
| 85 |
```
|
| 86 |
|
| 87 |
-
*Effects:* Constructs a *
|
| 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 |
-
|
| 93 |
```
|
| 94 |
|
| 95 |
-
*
|
| 96 |
-
`ator_traits::propagate_on_container_move_assignment` is `true`,
|
| 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
|
| 107 |
-
|
|
|
|
| 108 |
- Assigns `nullptr` to `nh.ptr_` and assigns `nullopt` to `nh.alloc_`.
|
| 109 |
|
| 110 |
*Returns:* `*this`.
|
| 111 |
|
| 112 |
*Throws:* Nothing.
|
| 113 |
|
| 114 |
-
####
|
| 115 |
|
| 116 |
``` cpp
|
| 117 |
-
~
|
| 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 |
-
####
|
| 126 |
|
| 127 |
``` cpp
|
| 128 |
value_type& value() const;
|
| 129 |
```
|
| 130 |
|
| 131 |
-
*
|
| 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 |
-
*
|
| 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 |
|
|
@@ -152,22 +156,22 @@ permitted.
|
|
| 152 |
|
| 153 |
``` cpp
|
| 154 |
mapped_type& mapped() const;
|
| 155 |
```
|
| 156 |
|
| 157 |
-
*
|
| 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 |
-
*
|
| 169 |
|
| 170 |
*Returns:* `*alloc_`.
|
| 171 |
|
| 172 |
*Throws:* Nothing.
|
| 173 |
|
|
@@ -176,26 +180,26 @@ 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 |
-
####
|
| 187 |
|
| 188 |
``` cpp
|
| 189 |
-
void swap(
|
| 190 |
noexcept(ator_traits::propagate_on_container_swap::value ||
|
| 191 |
ator_traits::is_always_equal::value);
|
| 192 |
```
|
| 193 |
|
| 194 |
-
*
|
| 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 |
|
|
|
|
| 1 |
### Node handles <a id="container.node">[[container.node]]</a>
|
| 2 |
|
| 3 |
+
#### 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 [[container.node.compat]].
|
| 12 |
|
| 13 |
+
**Table: Container types with compatible nodes** <a id="container.node.compat">[container.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>` |
|
|
|
|
| 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.
|
|
|
|
|
|
|
| 32 |
|
| 33 |
If a user-defined specialization of `pair` exists for
|
| 34 |
`pair<const Key, T>` or `pair<Key, T>`, where `Key` is the container’s
|
| 35 |
`key_type` and `T` is the container’s `mapped_type`, the behavior of
|
| 36 |
operations involving node handles is undefined.
|
| 37 |
|
| 38 |
``` cpp
|
| 39 |
template<unspecified>
|
| 40 |
+
class node-handle {
|
| 41 |
public:
|
| 42 |
+
// These type declarations are described in Tables [tab:container.assoc.req] and [tab:container.hash.req].
|
| 43 |
using value_type = see below; // not present for map containers
|
| 44 |
using key_type = see below; // not present for set containers
|
| 45 |
using mapped_type = see below; // not present for set containers
|
| 46 |
using allocator_type = see below;
|
| 47 |
|
| 48 |
private:
|
| 49 |
using container_node_type = unspecified;
|
| 50 |
using ator_traits = allocator_traits<allocator_type>;
|
| 51 |
|
| 52 |
+
typename ator_traits::template rebind_traits<container_node_type>::pointer ptr_;
|
| 53 |
optional<allocator_type> alloc_;
|
| 54 |
|
| 55 |
public:
|
| 56 |
+
// [container.node.cons], constructors, copy, and assignment
|
| 57 |
+
constexpr node-handle() noexcept : ptr_(), alloc_() {}
|
| 58 |
+
node-handle(node-handle&&) noexcept;
|
| 59 |
+
node-handle& operator=(node-handle&&);
|
| 60 |
|
| 61 |
+
// [container.node.dtor], destructor
|
| 62 |
+
~node-handle();
|
| 63 |
+
|
| 64 |
+
// [container.node.observers], observers
|
| 65 |
value_type& value() const; // not present for map containers
|
| 66 |
key_type& key() const; // not present for set containers
|
| 67 |
mapped_type& mapped() const; // not present for set containers
|
| 68 |
|
| 69 |
allocator_type get_allocator() const;
|
| 70 |
explicit operator bool() const noexcept;
|
| 71 |
+
[[nodiscard]] bool empty() const noexcept;
|
| 72 |
|
| 73 |
+
// [container.node.modifiers], modifiers
|
| 74 |
+
void swap(node-handle&)
|
| 75 |
noexcept(ator_traits::propagate_on_container_swap::value ||
|
| 76 |
ator_traits::is_always_equal::value);
|
| 77 |
|
| 78 |
+
friend void swap(node-handle& x, node-handle& y) noexcept(noexcept(x.swap(y))) {
|
| 79 |
x.swap(y);
|
| 80 |
}
|
| 81 |
};
|
| 82 |
```
|
| 83 |
|
| 84 |
+
#### Constructors, copy, and assignment <a id="container.node.cons">[[container.node.cons]]</a>
|
| 85 |
|
| 86 |
``` cpp
|
| 87 |
+
node-handle(node-handle&& nh) noexcept;
|
| 88 |
```
|
| 89 |
|
| 90 |
+
*Effects:* Constructs a *node-handle* object initializing `ptr_` with
|
| 91 |
`nh.ptr_`. Move constructs `alloc_` with `nh.alloc_`. Assigns `nullptr`
|
| 92 |
to `nh.ptr_` and assigns `nullopt` to `nh.alloc_`.
|
| 93 |
|
| 94 |
``` cpp
|
| 95 |
+
node-handle& operator=(node-handle&& nh);
|
| 96 |
```
|
| 97 |
|
| 98 |
+
*Preconditions:* Either `!alloc_`, or
|
| 99 |
+
`ator_traits::propagate_on_container_move_assignment::value` is `true`,
|
| 100 |
+
or `alloc_ == nh.alloc_`.
|
| 101 |
|
| 102 |
*Effects:*
|
| 103 |
|
| 104 |
- If `ptr_ != nullptr`, destroys the `value_type` subobject in the
|
| 105 |
`container_node_type` object pointed to by `ptr_` by calling
|
| 106 |
`ator_traits::destroy`, then deallocates `ptr_` by calling
|
| 107 |
+
`ator_traits::template rebind_traits<container_node_type>::deallocate`.
|
| 108 |
- Assigns `nh.ptr_` to `ptr_`.
|
| 109 |
+
- If `!alloc` or
|
| 110 |
+
`ator_traits::propagate_on_container_move_assignment::value` is
|
| 111 |
+
`true`, move assigns `nh.alloc_` to `alloc_`.
|
| 112 |
- Assigns `nullptr` to `nh.ptr_` and assigns `nullopt` to `nh.alloc_`.
|
| 113 |
|
| 114 |
*Returns:* `*this`.
|
| 115 |
|
| 116 |
*Throws:* Nothing.
|
| 117 |
|
| 118 |
+
#### Destructor <a id="container.node.dtor">[[container.node.dtor]]</a>
|
| 119 |
|
| 120 |
``` cpp
|
| 121 |
+
~node-handle();
|
| 122 |
```
|
| 123 |
|
| 124 |
*Effects:* If `ptr_ != nullptr`, destroys the `value_type` subobject in
|
| 125 |
the `container_node_type` object pointed to by `ptr_` by calling
|
| 126 |
`ator_traits::destroy`, then deallocates `ptr_` by calling
|
| 127 |
+
`ator_traits::template rebind_traits<container_node_type>::deallocate`.
|
| 128 |
|
| 129 |
+
#### Observers <a id="container.node.observers">[[container.node.observers]]</a>
|
| 130 |
|
| 131 |
``` cpp
|
| 132 |
value_type& value() const;
|
| 133 |
```
|
| 134 |
|
| 135 |
+
*Preconditions:* `empty() == false`.
|
| 136 |
|
| 137 |
*Returns:* A reference to the `value_type` subobject in the
|
| 138 |
`container_node_type` object pointed to by `ptr_`.
|
| 139 |
|
| 140 |
*Throws:* Nothing.
|
| 141 |
|
| 142 |
``` cpp
|
| 143 |
key_type& key() const;
|
| 144 |
```
|
| 145 |
|
| 146 |
+
*Preconditions:* `empty() == false`.
|
| 147 |
|
| 148 |
*Returns:* A non-const reference to the `key_type` member of the
|
| 149 |
`value_type` subobject in the `container_node_type` object pointed to by
|
| 150 |
`ptr_`.
|
| 151 |
|
|
|
|
| 156 |
|
| 157 |
``` cpp
|
| 158 |
mapped_type& mapped() const;
|
| 159 |
```
|
| 160 |
|
| 161 |
+
*Preconditions:* `empty() == false`.
|
| 162 |
|
| 163 |
*Returns:* A reference to the `mapped_type` member of the `value_type`
|
| 164 |
subobject in the `container_node_type` object pointed to by `ptr_`.
|
| 165 |
|
| 166 |
*Throws:* Nothing.
|
| 167 |
|
| 168 |
``` cpp
|
| 169 |
allocator_type get_allocator() const;
|
| 170 |
```
|
| 171 |
|
| 172 |
+
*Preconditions:* `empty() == false`.
|
| 173 |
|
| 174 |
*Returns:* `*alloc_`.
|
| 175 |
|
| 176 |
*Throws:* Nothing.
|
| 177 |
|
|
|
|
| 180 |
```
|
| 181 |
|
| 182 |
*Returns:* `ptr_ != nullptr`.
|
| 183 |
|
| 184 |
``` cpp
|
| 185 |
+
[[nodiscard]] bool empty() const noexcept;
|
| 186 |
```
|
| 187 |
|
| 188 |
*Returns:* `ptr_ == nullptr`.
|
| 189 |
|
| 190 |
+
#### Modifiers <a id="container.node.modifiers">[[container.node.modifiers]]</a>
|
| 191 |
|
| 192 |
``` cpp
|
| 193 |
+
void swap(node-handle& nh)
|
| 194 |
noexcept(ator_traits::propagate_on_container_swap::value ||
|
| 195 |
ator_traits::is_always_equal::value);
|
| 196 |
```
|
| 197 |
|
| 198 |
+
*Preconditions:* `!alloc_`, or `!nh.alloc_`, or
|
| 199 |
+
`ator_traits::propagate_on_container_swap::value` is `true`, or
|
| 200 |
`alloc_ == nh.alloc_`.
|
| 201 |
|
| 202 |
*Effects:* Calls `swap(ptr_, nh.ptr_)`. If `!alloc_`, or `!nh.alloc_`,
|
| 203 |
+
or `ator_traits::propagate_on_container_swap::value` is `true` calls
|
| 204 |
`swap(alloc_, nh.alloc_)`.
|
| 205 |
|