From Jason Turner

[mem.poly.allocator.mem]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpfhzxbj5i/{from.md → to.md} +166 -0
tmp/tmpfhzxbj5i/{from.md → to.md} RENAMED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### `polymorphic_allocator` member functions <a id="mem.poly.allocator.mem">[[mem.poly.allocator.mem]]</a>
2
+
3
+ ``` cpp
4
+ Tp* allocate(size_t n);
5
+ ```
6
+
7
+ *Returns:* Equivalent to
8
+
9
+ ``` cpp
10
+ return static_cast<Tp*>(memory_rsrc->allocate(n * sizeof(Tp), alignof(Tp)));
11
+ ```
12
+
13
+ ``` cpp
14
+ void deallocate(Tp* p, size_t n);
15
+ ```
16
+
17
+ *Requires:* `p` was allocated from a memory resource `x`, equal to
18
+ `*memory_rsrc`, using `x.allocate(n * sizeof(Tp), alignof(Tp))`.
19
+
20
+ *Effects:* Equivalent to
21
+ `memory_rsrc->deallocate(p, n * sizeof(Tp), alignof(Tp))`.
22
+
23
+ *Throws:* Nothing.
24
+
25
+ ``` cpp
26
+ template <class T, class... Args>
27
+ void construct(T* p, Args&&... args);
28
+ ```
29
+
30
+ *Requires:* Uses-allocator construction of `T` with allocator
31
+ `resource()` (see  [[allocator.uses.construction]]) and constructor
32
+ arguments `std::forward<Args>(args)...` is well-formed.
33
+
34
+ [*Note 1*: Uses-allocator construction is always well formed for types
35
+ that do not use allocators. — *end note*]
36
+
37
+ *Effects:* Construct a `T` object in the storage whose address is
38
+ represented by `p` by uses-allocator construction with allocator
39
+ `resource()` and constructor arguments `std::forward<Args>(args)...`.
40
+
41
+ *Throws:* Nothing unless the constructor for `T` throws.
42
+
43
+ ``` cpp
44
+ template <class T1, class T2, class... Args1, class... Args2>
45
+ void construct(pair<T1,T2>* p, piecewise_construct_t,
46
+ tuple<Args1...> x, tuple<Args2...> y);
47
+ ```
48
+
49
+ [*Note 2*: This method and the `construct` methods that follow are
50
+ overloads for piecewise construction of
51
+ pairs ([[pairs.pair]]). — *end note*]
52
+
53
+ *Effects:* Let `xprime` be a `tuple` constructed from `x` according to
54
+ the appropriate rule from the following list.
55
+
56
+ [*Note 3*: The following description can be summarized as constructing
57
+ a `pair<T1, T2>` object in the storage whose address is represented by
58
+ `p`, as if by separate uses-allocator construction with allocator
59
+ `resource()` ([[allocator.uses.construction]]) of `p->first` using the
60
+ elements of `x` and `p->second` using the elements of
61
+ `y`. — *end note*]
62
+
63
+ - If `uses_allocator_v<T1,memory_resource*>` is `false`
64
+ and `is_constructible_v<T1,Args1...>` is `true`,
65
+ then `xprime` is `x`.
66
+ - Otherwise, if `uses_allocator_v<T1,memory_resource*>` is `true`
67
+ and `is_constructible_v<T1,allocator_arg_t,memory_resource*,Args1...>`
68
+ is `true`,
69
+ then `xprime` is
70
+ `tuple_cat(make_tuple(allocator_arg, resource()), std::move(x))`.
71
+ - Otherwise, if `uses_allocator_v<T1,memory_resource*>` is `true`
72
+ and `is_constructible_v<T1,Args1...,memory_resource*>` is `true`,
73
+ then `xprime` is `tuple_cat(std::move(x), make_tuple(resource()))`.
74
+ - Otherwise the program is ill formed.
75
+
76
+ Let `yprime` be a tuple constructed from `y` according to the
77
+ appropriate rule from the following list:
78
+
79
+ - If `uses_allocator_v<T2,memory_resource*>` is `false`
80
+ and `is_constructible_v<T2,Args2...>` is `true`,
81
+ then `yprime` is `y`.
82
+ - Otherwise, if `uses_allocator_v<T2,memory_resource*>` is `true`
83
+ and `is_constructible_v<T2,allocator_arg_t,memory_resource*,Args2...>`
84
+ is `true`,
85
+ then `yprime` is
86
+ `tuple_cat(make_tuple(allocator_arg, resource()), std::move(y))`.
87
+ - Otherwise, if `uses_allocator_v<T2,memory_resource*>` is `true`
88
+ and `is_constructible_v<T2,Args2...,memory_resource*>` is `true`,
89
+ then `yprime` is `tuple_cat(std::move(y), make_tuple(resource()))`.
90
+ - Otherwise the program is ill formed.
91
+
92
+ Then, using `piecewise_construct`, `xprime`, and `yprime` as the
93
+ constructor arguments, this function constructs a `pair<T1, T2>` object
94
+ in the storage whose address is represented by `p`.
95
+
96
+ ``` cpp
97
+ template <class T1, class T2>
98
+ void construct(pair<T1,T2>* p);
99
+ ```
100
+
101
+ *Effects:* Equivalent to:
102
+
103
+ ``` cpp
104
+ construct(p, piecewise_construct, tuple<>(), tuple<>());
105
+ ```
106
+
107
+ ``` cpp
108
+ template <class T1, class T2, class U, class V>
109
+ void construct(pair<T1,T2>* p, U&& x, V&& y);
110
+ ```
111
+
112
+ *Effects:* Equivalent to:
113
+
114
+ ``` cpp
115
+ construct(p, piecewise_construct,
116
+ forward_as_tuple(std::forward<U>(x)),
117
+ forward_as_tuple(std::forward<V>(y)));
118
+ ```
119
+
120
+ ``` cpp
121
+ template <class T1, class T2, class U, class V>
122
+ void construct(pair<T1,T2>* p, const pair<U, V>& pr);
123
+ ```
124
+
125
+ *Effects:* Equivalent to:
126
+
127
+ ``` cpp
128
+ construct(p, piecewise_construct,
129
+ forward_as_tuple(pr.first),
130
+ forward_as_tuple(pr.second));
131
+ ```
132
+
133
+ ``` cpp
134
+ template <class T1, class T2, class U, class V>
135
+ void construct(pair<T1,T2>* p, pair<U, V>&& pr);
136
+ ```
137
+
138
+ *Effects:* Equivalent to:
139
+
140
+ ``` cpp
141
+ construct(p, piecewise_construct,
142
+ forward_as_tuple(std::forward<U>(pr.first)),
143
+ forward_as_tuple(std::forward<V>(pr.second)));
144
+ ```
145
+
146
+ ``` cpp
147
+ template <class T>
148
+ void destroy(T* p);
149
+ ```
150
+
151
+ *Effects:* As if by `p->T̃()`.
152
+
153
+ ``` cpp
154
+ polymorphic_allocator select_on_container_copy_construction() const;
155
+ ```
156
+
157
+ *Returns:* `polymorphic_allocator()`.
158
+
159
+ [*Note 4*: The memory resource is not propagated. — *end note*]
160
+
161
+ ``` cpp
162
+ memory_resource* resource() const;
163
+ ```
164
+
165
+ *Returns:* `memory_rsrc`.
166
+