From Jason Turner

[container.alloc.reqmts]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpfxg_5fqq/{from.md → to.md} +190 -0
tmp/tmpfxg_5fqq/{from.md → to.md} RENAMED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Allocator-aware containers <a id="container.alloc.reqmts">[[container.alloc.reqmts]]</a>
2
+
3
+ All of the containers defined in [[containers]] and in  [[basic.string]]
4
+ except `array` meet the additional requirements of an
5
+ *allocator-aware container*, as described below.
6
+
7
+ Given an allocator type `A` and given a container type `X` having a
8
+ `value_type` identical to `T` and an `allocator_type` identical to
9
+ `allocator_traits<A>::rebind_alloc<T>` and given an lvalue `m` of type
10
+ `A`, a pointer `p` of type `T*`, an expression `v` of type `T` or
11
+ `const T`, and an rvalue `rv` of type `T`, the following terms are
12
+ defined. If `X` is not allocator-aware or is a specialization of
13
+ `basic_string`, the terms below are defined as if `A` were
14
+ `allocator<T>` — no allocator object needs to be created and user
15
+ specializations of `allocator<T>` are not instantiated:
16
+
17
+ - `T` is **Cpp17DefaultInsertable* into `X`* means that the following
18
+ expression is well-formed:
19
+ ``` cpp
20
+ allocator_traits<A>::construct(m, p)
21
+ ```
22
+ - An element of `X` is *default-inserted* if it is initialized by
23
+ evaluation of the expression
24
+ ``` cpp
25
+ allocator_traits<A>::construct(m, p)
26
+ ```
27
+
28
+ where `p` is the address of the uninitialized storage for the element
29
+ allocated within `X`.
30
+ - `T` is **Cpp17MoveInsertable* into `X`* means that the following
31
+ expression is well-formed:
32
+ ``` cpp
33
+ allocator_traits<A>::construct(m, p, rv)
34
+ ```
35
+
36
+ and its evaluation causes the following postcondition to hold: The
37
+ value of `*p` is equivalent to the value of `rv` before the
38
+ evaluation.
39
+ \[*Note 1*: `rv` remains a valid object. Its state is
40
+ unspecified — *end note*]
41
+ - `T` is **Cpp17CopyInsertable* into `X`* means that, in addition to `T`
42
+ being *Cpp17MoveInsertable* into `X`, the following expression is
43
+ well-formed:
44
+ ``` cpp
45
+ allocator_traits<A>::construct(m, p, v)
46
+ ```
47
+
48
+ and its evaluation causes the following postcondition to hold: The
49
+ value of `v` is unchanged and is equivalent to `*p`.
50
+ - `T` is **Cpp17EmplaceConstructible* into `X` from `args`*, for zero or
51
+ more arguments `args`, means that the following expression is
52
+ well-formed:
53
+ ``` cpp
54
+ allocator_traits<A>::construct(m, p, args)
55
+ ```
56
+ - `T` is **Cpp17Erasable* from `X`* means that the following expression
57
+ is well-formed:
58
+ ``` cpp
59
+ allocator_traits<A>::destroy(m, p)
60
+ ```
61
+
62
+ [*Note 2*: A container calls
63
+ `allocator_traits<A>::construct(m, p, args)` to construct an element at
64
+ `p` using `args`, with `m == get_allocator()`. The default `construct`
65
+ in `allocator` will call `::new((void*)p) T(args)`, but specialized
66
+ allocators can choose a different definition. — *end note*]
67
+
68
+ In this subclause,
69
+
70
+ - `X` denotes an allocator-aware container class with a `value_type` of
71
+ `T` using an allocator of type `A`,
72
+ - `u` denotes a variable,
73
+ - `a` and `b` denote non-const lvalues of type `X`,
74
+ - `c` denotes an lvalue of type `const X`,
75
+ - `t` denotes an lvalue or a const rvalue of type `X`,
76
+ - `rv` denotes a non-const rvalue of type `X`, and
77
+ - `m` is a value of type `A`.
78
+
79
+ A type `X` meets the allocator-aware container requirements if `X` meets
80
+ the container requirements and the following types, statements, and
81
+ expressions are well-formed and have the specified semantics.
82
+
83
+ ``` cpp
84
+ typename X::allocator_type
85
+ ```
86
+
87
+ *Result:* `A`
88
+
89
+ *Mandates:* `allocator_type::value_type` is the same as `X::value_type`.
90
+
91
+ ``` cpp
92
+ c.get_allocator()
93
+ ```
94
+
95
+ *Result:* `A`
96
+
97
+ *Complexity:* Constant.
98
+
99
+ ``` cpp
100
+ X u;
101
+ X u = X();
102
+ ```
103
+
104
+ *Preconditions:* `A` meets the *Cpp17DefaultConstructible* requirements.
105
+
106
+ *Ensures:* `u.empty()` returns `true`, `u.get_allocator() == A()`.
107
+
108
+ *Complexity:* Constant.
109
+
110
+ ``` cpp
111
+ X u(m);
112
+ ```
113
+
114
+ *Ensures:* `u.empty()` returns `true`, `u.get_allocator() == m`.
115
+
116
+ *Complexity:* Constant.
117
+
118
+ ``` cpp
119
+ X u(t, m);
120
+ ```
121
+
122
+ *Preconditions:* `T` is *Cpp17CopyInsertable* into `X`.
123
+
124
+ *Ensures:* `u == t`, `u.get_allocator() == m`
125
+
126
+ *Complexity:* Linear.
127
+
128
+ ``` cpp
129
+ X u(rv);
130
+ ```
131
+
132
+ *Ensures:* `u` has the same elements as `rv` had before this
133
+ construction; the value of `u.get_allocator()` is the same as the value
134
+ of `rv.get_allocator()` before this construction.
135
+
136
+ *Complexity:* Constant.
137
+
138
+ ``` cpp
139
+ X u(rv, m);
140
+ ```
141
+
142
+ *Preconditions:* `T` is *Cpp17MoveInsertable* into `X`.
143
+
144
+ *Ensures:* `u` has the same elements, or copies of the elements, that
145
+ `rv` had before this construction, `u.get_allocator() == m`.
146
+
147
+ *Complexity:* Constant if `m == rv.get_allocator()`, otherwise linear.
148
+
149
+ ``` cpp
150
+ a = t
151
+ ```
152
+
153
+ *Result:* `X&`.
154
+
155
+ *Preconditions:* `T` is *Cpp17CopyInsertable* into `X` and
156
+ *Cpp17CopyAssignable*.
157
+
158
+ *Ensures:* `a == t` is `true`.
159
+
160
+ *Complexity:* Linear.
161
+
162
+ ``` cpp
163
+ a = rv
164
+ ```
165
+
166
+ *Result:* `X&`.
167
+
168
+ *Preconditions:* If
169
+ `allocator_traits<allocator_type>::propagate_on_container_move_assignment::value`
170
+ is `false`, `T` is *Cpp17MoveInsertable* into `X` and
171
+ *Cpp17MoveAssignable*.
172
+
173
+ *Effects:* All existing elements of `a` are either move assigned to or
174
+ destroyed.
175
+
176
+ *Ensures:* If `a` and `rv` do not refer to the same object, `a` is equal
177
+ to the value that `rv` had before this assignment.
178
+
179
+ *Complexity:* Linear.
180
+
181
+ ``` cpp
182
+ a.swap(b)
183
+ ```
184
+
185
+ *Result:* `void`
186
+
187
+ *Effects:* Exchanges the contents of `a` and `b`.
188
+
189
+ *Complexity:* Constant.
190
+