tmp/tmpz47qoczo/{from.md → to.md}
RENAMED
|
@@ -1,30 +1,33 @@
|
|
| 1 |
### Allocator traits <a id="allocator.traits">[[allocator.traits]]</a>
|
| 2 |
|
| 3 |
The class template `allocator_traits` supplies a uniform interface to
|
| 4 |
all allocator types. An allocator cannot be a non-class type, however,
|
| 5 |
-
even if `allocator_traits` supplies the entire required interface.
|
| 6 |
-
|
|
|
|
|
|
|
| 7 |
|
| 8 |
``` cpp
|
| 9 |
namespace std {
|
| 10 |
template <class Alloc> struct allocator_traits {
|
| 11 |
-
|
| 12 |
|
| 13 |
-
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
| 26 |
|
| 27 |
template <class T> using rebind_alloc = see below;
|
| 28 |
template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>;
|
| 29 |
|
| 30 |
static pointer allocate(Alloc& a, size_type n);
|
|
@@ -46,80 +49,99 @@ namespace std {
|
|
| 46 |
```
|
| 47 |
|
| 48 |
#### Allocator traits member types <a id="allocator.traits.types">[[allocator.traits.types]]</a>
|
| 49 |
|
| 50 |
``` cpp
|
| 51 |
-
|
| 52 |
```
|
| 53 |
|
| 54 |
-
*Type:* `Alloc::pointer` if
|
| 55 |
-
`value_type*`.
|
| 56 |
|
| 57 |
``` cpp
|
| 58 |
-
|
| 59 |
```
|
| 60 |
|
| 61 |
-
*Type:* `Alloc::const_pointer` if
|
| 62 |
-
`
|
|
|
|
| 63 |
|
| 64 |
``` cpp
|
| 65 |
-
|
| 66 |
```
|
| 67 |
|
| 68 |
-
*Type:* `Alloc::void_pointer` if
|
| 69 |
-
`
|
|
|
|
| 70 |
|
| 71 |
``` cpp
|
| 72 |
-
|
| 73 |
```
|
| 74 |
|
| 75 |
-
*Type:* `Alloc::const_void_pointer` if
|
|
|
|
|
|
|
| 76 |
`pointer_traits<pointer>::rebind<const void>`.
|
| 77 |
|
| 78 |
``` cpp
|
| 79 |
-
|
| 80 |
```
|
| 81 |
|
| 82 |
-
*Type:* `Alloc::difference_type` if
|
| 83 |
-
`
|
|
|
|
| 84 |
|
| 85 |
``` cpp
|
| 86 |
-
|
| 87 |
```
|
| 88 |
|
| 89 |
-
*Type:* `Alloc::size_type` if
|
|
|
|
| 90 |
`make_unsigned_t<difference_type>`.
|
| 91 |
|
| 92 |
``` cpp
|
| 93 |
-
|
| 94 |
```
|
| 95 |
|
| 96 |
-
*Type:* `Alloc::propagate_on_container_copy_assignment` if
|
| 97 |
-
|
|
|
|
| 98 |
|
| 99 |
``` cpp
|
| 100 |
-
|
| 101 |
```
|
| 102 |
|
| 103 |
-
*Type:* `Alloc::propagate_on_container_move_assignment` if
|
| 104 |
-
|
|
|
|
| 105 |
|
| 106 |
``` cpp
|
| 107 |
-
|
| 108 |
```
|
| 109 |
|
| 110 |
-
*Type:* `Alloc::propagate_on_container_swap` if
|
| 111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
|
| 113 |
``` cpp
|
| 114 |
template <class T> using rebind_alloc = see below;
|
| 115 |
```
|
| 116 |
|
| 117 |
-
*Alias template:* `Alloc::rebind<T>::other` if
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
|
|
|
|
|
|
| 121 |
|
| 122 |
#### Allocator traits static member functions <a id="allocator.traits.members">[[allocator.traits.members]]</a>
|
| 123 |
|
| 124 |
``` cpp
|
| 125 |
static pointer allocate(Alloc& a, size_type n);
|
|
@@ -136,37 +158,37 @@ otherwise, `a.allocate(n)`.
|
|
| 136 |
|
| 137 |
``` cpp
|
| 138 |
static void deallocate(Alloc& a, pointer p, size_type n);
|
| 139 |
```
|
| 140 |
|
| 141 |
-
*Effects:*
|
| 142 |
|
| 143 |
*Throws:* Nothing.
|
| 144 |
|
| 145 |
``` cpp
|
| 146 |
template <class T, class... Args>
|
| 147 |
static void construct(Alloc& a, T* p, Args&&... args);
|
| 148 |
```
|
| 149 |
|
| 150 |
-
*Effects:*
|
| 151 |
call is well-formed; otherwise, invokes
|
| 152 |
`::new (static_cast<void*>(p)) T(std::forward<Args>(args)...)`.
|
| 153 |
|
| 154 |
``` cpp
|
| 155 |
template <class T>
|
| 156 |
static void destroy(Alloc& a, T* p);
|
| 157 |
```
|
| 158 |
|
| 159 |
-
*Effects:*
|
| 160 |
invokes `p->~T()`.
|
| 161 |
|
| 162 |
``` cpp
|
| 163 |
static size_type max_size(const Alloc& a) noexcept;
|
| 164 |
```
|
| 165 |
|
| 166 |
*Returns:* `a.max_size()` if that expression is well-formed; otherwise,
|
| 167 |
-
`numeric_limits<size_type>::max()`.
|
| 168 |
|
| 169 |
``` cpp
|
| 170 |
static Alloc select_on_container_copy_construction(const Alloc& rhs);
|
| 171 |
```
|
| 172 |
|
|
|
|
| 1 |
### Allocator traits <a id="allocator.traits">[[allocator.traits]]</a>
|
| 2 |
|
| 3 |
The class template `allocator_traits` supplies a uniform interface to
|
| 4 |
all allocator types. An allocator cannot be a non-class type, however,
|
| 5 |
+
even if `allocator_traits` supplies the entire required interface.
|
| 6 |
+
|
| 7 |
+
[*Note 1*: Thus, it is always possible to create a derived class from
|
| 8 |
+
an allocator. — *end note*]
|
| 9 |
|
| 10 |
``` cpp
|
| 11 |
namespace std {
|
| 12 |
template <class Alloc> struct allocator_traits {
|
| 13 |
+
using allocator_type = Alloc;
|
| 14 |
|
| 15 |
+
using value_type = typename Alloc::value_type;
|
| 16 |
|
| 17 |
+
using pointer = see below;
|
| 18 |
+
using const_pointer = see below;
|
| 19 |
+
using void_pointer = see below;
|
| 20 |
+
using const_void_pointer = see below;
|
| 21 |
|
| 22 |
+
using difference_type = see below;
|
| 23 |
+
using size_type = see below;
|
| 24 |
|
| 25 |
+
using propagate_on_container_copy_assignment = see below;
|
| 26 |
+
using propagate_on_container_move_assignment = see below;
|
| 27 |
+
using propagate_on_container_swap = see below;
|
| 28 |
+
using is_always_equal = see below;
|
| 29 |
|
| 30 |
template <class T> using rebind_alloc = see below;
|
| 31 |
template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>;
|
| 32 |
|
| 33 |
static pointer allocate(Alloc& a, size_type n);
|
|
|
|
| 49 |
```
|
| 50 |
|
| 51 |
#### Allocator traits member types <a id="allocator.traits.types">[[allocator.traits.types]]</a>
|
| 52 |
|
| 53 |
``` cpp
|
| 54 |
+
using pointer = see below;
|
| 55 |
```
|
| 56 |
|
| 57 |
+
*Type:* `Alloc::pointer` if the *qualified-id* `Alloc::pointer` is valid
|
| 58 |
+
and denotes a type ([[temp.deduct]]); otherwise, `value_type*`.
|
| 59 |
|
| 60 |
``` cpp
|
| 61 |
+
using const_pointer = see below;
|
| 62 |
```
|
| 63 |
|
| 64 |
+
*Type:* `Alloc::const_pointer` if the *qualified-id*
|
| 65 |
+
`Alloc::const_pointer` is valid and denotes a type ([[temp.deduct]]);
|
| 66 |
+
otherwise, `pointer_traits<pointer>::rebind<const value_type>`.
|
| 67 |
|
| 68 |
``` cpp
|
| 69 |
+
using void_pointer = see below;
|
| 70 |
```
|
| 71 |
|
| 72 |
+
*Type:* `Alloc::void_pointer` if the *qualified-id*
|
| 73 |
+
`Alloc::void_pointer` is valid and denotes a type ([[temp.deduct]]);
|
| 74 |
+
otherwise, `pointer_traits<pointer>::rebind<void>`.
|
| 75 |
|
| 76 |
``` cpp
|
| 77 |
+
using const_void_pointer = see below;
|
| 78 |
```
|
| 79 |
|
| 80 |
+
*Type:* `Alloc::const_void_pointer` if the *qualified-id*
|
| 81 |
+
`Alloc::const_void_pointer` is valid and denotes a
|
| 82 |
+
type ([[temp.deduct]]); otherwise,
|
| 83 |
`pointer_traits<pointer>::rebind<const void>`.
|
| 84 |
|
| 85 |
``` cpp
|
| 86 |
+
using difference_type = see below;
|
| 87 |
```
|
| 88 |
|
| 89 |
+
*Type:* `Alloc::difference_type` if the *qualified-id*
|
| 90 |
+
`Alloc::difference_type` is valid and denotes a type ([[temp.deduct]]);
|
| 91 |
+
otherwise, `pointer_traits<pointer>::difference_type`.
|
| 92 |
|
| 93 |
``` cpp
|
| 94 |
+
using size_type = see below;
|
| 95 |
```
|
| 96 |
|
| 97 |
+
*Type:* `Alloc::size_type` if the *qualified-id* `Alloc::size_type` is
|
| 98 |
+
valid and denotes a type ([[temp.deduct]]); otherwise,
|
| 99 |
`make_unsigned_t<difference_type>`.
|
| 100 |
|
| 101 |
``` cpp
|
| 102 |
+
using propagate_on_container_copy_assignment = see below;
|
| 103 |
```
|
| 104 |
|
| 105 |
+
*Type:* `Alloc::propagate_on_container_copy_assignment` if the
|
| 106 |
+
*qualified-id* `Alloc::propagate_on_container_copy_assignment` is valid
|
| 107 |
+
and denotes a type ([[temp.deduct]]); otherwise `false_type`.
|
| 108 |
|
| 109 |
``` cpp
|
| 110 |
+
using propagate_on_container_move_assignment = see below;
|
| 111 |
```
|
| 112 |
|
| 113 |
+
*Type:* `Alloc::propagate_on_container_move_assignment` if the
|
| 114 |
+
*qualified-id* `Alloc::propagate_on_container_move_assignment` is valid
|
| 115 |
+
and denotes a type ([[temp.deduct]]); otherwise `false_type`.
|
| 116 |
|
| 117 |
``` cpp
|
| 118 |
+
using propagate_on_container_swap = see below;
|
| 119 |
```
|
| 120 |
|
| 121 |
+
*Type:* `Alloc::propagate_on_container_swap` if the *qualified-id*
|
| 122 |
+
`Alloc::propagate_on_container_swap` is valid and denotes a
|
| 123 |
+
type ([[temp.deduct]]); otherwise `false_type`.
|
| 124 |
+
|
| 125 |
+
``` cpp
|
| 126 |
+
using is_always_equal = see below;
|
| 127 |
+
```
|
| 128 |
+
|
| 129 |
+
*Type:* `Alloc::is_always_equal` if the *qualified-id*
|
| 130 |
+
`Alloc::is_always_equal` is valid and denotes a type ([[temp.deduct]]);
|
| 131 |
+
otherwise `is_empty<Alloc>::type`.
|
| 132 |
|
| 133 |
``` cpp
|
| 134 |
template <class T> using rebind_alloc = see below;
|
| 135 |
```
|
| 136 |
|
| 137 |
+
*Alias template:* `Alloc::rebind<T>::other` if the *qualified-id*
|
| 138 |
+
`Alloc::rebind<T>::other` is valid and denotes a
|
| 139 |
+
type ([[temp.deduct]]); otherwise, `Alloc<T, Args>` if `Alloc` is a
|
| 140 |
+
class template instantiation of the form `Alloc<U, Args>`, where `Args`
|
| 141 |
+
is zero or more type arguments; otherwise, the instantiation of
|
| 142 |
+
`rebind_alloc` is ill-formed.
|
| 143 |
|
| 144 |
#### Allocator traits static member functions <a id="allocator.traits.members">[[allocator.traits.members]]</a>
|
| 145 |
|
| 146 |
``` cpp
|
| 147 |
static pointer allocate(Alloc& a, size_type n);
|
|
|
|
| 158 |
|
| 159 |
``` cpp
|
| 160 |
static void deallocate(Alloc& a, pointer p, size_type n);
|
| 161 |
```
|
| 162 |
|
| 163 |
+
*Effects:* Calls `a.deallocate(p, n)`.
|
| 164 |
|
| 165 |
*Throws:* Nothing.
|
| 166 |
|
| 167 |
``` cpp
|
| 168 |
template <class T, class... Args>
|
| 169 |
static void construct(Alloc& a, T* p, Args&&... args);
|
| 170 |
```
|
| 171 |
|
| 172 |
+
*Effects:* Calls `a.construct(p, std::forward<Args>(args)...)` if that
|
| 173 |
call is well-formed; otherwise, invokes
|
| 174 |
`::new (static_cast<void*>(p)) T(std::forward<Args>(args)...)`.
|
| 175 |
|
| 176 |
``` cpp
|
| 177 |
template <class T>
|
| 178 |
static void destroy(Alloc& a, T* p);
|
| 179 |
```
|
| 180 |
|
| 181 |
+
*Effects:* Calls `a.destroy(p)` if that call is well-formed; otherwise,
|
| 182 |
invokes `p->~T()`.
|
| 183 |
|
| 184 |
``` cpp
|
| 185 |
static size_type max_size(const Alloc& a) noexcept;
|
| 186 |
```
|
| 187 |
|
| 188 |
*Returns:* `a.max_size()` if that expression is well-formed; otherwise,
|
| 189 |
+
`numeric_limits<size_type>::max()/sizeof(value_type)`.
|
| 190 |
|
| 191 |
``` cpp
|
| 192 |
static Alloc select_on_container_copy_construction(const Alloc& rhs);
|
| 193 |
```
|
| 194 |
|