From Jason Turner

[mem.poly.allocator.class]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpvgrua9lb/{from.md → to.md} +16 -16
tmp/tmpvgrua9lb/{from.md → to.md} RENAMED
@@ -1,19 +1,23 @@
1
  ### Class template `polymorphic_allocator` <a id="mem.poly.allocator.class">[[mem.poly.allocator.class]]</a>
2
 
 
 
3
  A specialization of class template `pmr::polymorphic_allocator` meets
4
- the *Cpp17Allocator* requirements ([[cpp17.allocator]]). Constructed
5
- with different memory resources, different instances of the same
 
6
  specialization of `pmr::polymorphic_allocator` can exhibit entirely
7
  different allocation behavior. This runtime polymorphism allows objects
8
  that use `polymorphic_allocator` to behave as if they used different
9
  allocator types at run time even though they use the same static
10
  allocator type.
11
 
12
- All specializations of class template `pmr::polymorphic_allocator` meet
13
  the allocator completeness requirements
14
- [[allocator.requirements.completeness]].
 
15
 
16
  ``` cpp
17
  namespace std::pmr {
18
  template<class Tp = byte> class polymorphic_allocator {
19
  memory_resource* memory_rsrc; // exposition only
@@ -44,16 +48,19 @@ namespace std::pmr {
44
  template<class T> void delete_object(T* p);
45
 
46
  template<class T, class... Args>
47
  void construct(T* p, Args&&... args);
48
 
49
- template<class T>
50
- void destroy(T* p);
51
-
52
  polymorphic_allocator select_on_container_copy_construction() const;
53
 
54
  memory_resource* resource() const;
 
 
 
 
 
 
55
  };
56
  }
57
  ```
58
 
59
  #### Constructors <a id="mem.poly.allocator.ctor">[[mem.poly.allocator.ctor]]</a>
@@ -151,11 +158,11 @@ template<class T>
151
  ```
152
 
153
  *Effects:* Equivalent to `deallocate_bytes(p, n*sizeof(T), alignof(T))`.
154
 
155
  ``` cpp
156
- template<class T, class CtorArgs...>
157
  [[nodiscard]] T* new_object(CtorArgs&&... ctor_args);
158
  ```
159
 
160
  *Effects:* Allocates and constructs an object of type `T`, as follows.
161
  Equivalent to:
@@ -180,11 +187,11 @@ template<class T>
180
  ```
181
 
182
  *Effects:* Equivalent to:
183
 
184
  ``` cpp
185
- destroy(p);
186
  deallocate_object(p);
187
  ```
188
 
189
  ``` cpp
190
  template<class T, class... Args>
@@ -199,17 +206,10 @@ template<class T, class... Args>
199
  represented by `p` by uses-allocator construction with allocator `*this`
200
  and constructor arguments `std::forward<Args>(args)...`.
201
 
202
  *Throws:* Nothing unless the constructor for `T` throws.
203
 
204
- ``` cpp
205
- template<class T>
206
- void destroy(T* p);
207
- ```
208
-
209
- *Effects:* As if by `p->T̃()`.
210
-
211
  ``` cpp
212
  polymorphic_allocator select_on_container_copy_construction() const;
213
  ```
214
 
215
  *Returns:* `polymorphic_allocator()`.
 
1
  ### Class template `polymorphic_allocator` <a id="mem.poly.allocator.class">[[mem.poly.allocator.class]]</a>
2
 
3
+ #### General <a id="mem.poly.allocator.class.general">[[mem.poly.allocator.class.general]]</a>
4
+
5
  A specialization of class template `pmr::polymorphic_allocator` meets
6
+ the *Cpp17Allocator* requirements [[allocator.requirements.general]] if
7
+ its template argument is a cv-unqualified object type. Constructed with
8
+ different memory resources, different instances of the same
9
  specialization of `pmr::polymorphic_allocator` can exhibit entirely
10
  different allocation behavior. This runtime polymorphism allows objects
11
  that use `polymorphic_allocator` to behave as if they used different
12
  allocator types at run time even though they use the same static
13
  allocator type.
14
 
15
+ A specialization of class template `pmr::polymorphic_allocator` meets
16
  the allocator completeness requirements
17
+ [[allocator.requirements.completeness]] if its template argument is a
18
+ cv-unqualified object type.
19
 
20
  ``` cpp
21
  namespace std::pmr {
22
  template<class Tp = byte> class polymorphic_allocator {
23
  memory_resource* memory_rsrc; // exposition only
 
48
  template<class T> void delete_object(T* p);
49
 
50
  template<class T, class... Args>
51
  void construct(T* p, Args&&... args);
52
 
 
 
 
53
  polymorphic_allocator select_on_container_copy_construction() const;
54
 
55
  memory_resource* resource() const;
56
+
57
+ // friends
58
+ friend bool operator==(const polymorphic_allocator& a,
59
+ const polymorphic_allocator& b) noexcept {
60
+ return *a.resource() == *b.resource();
61
+ }
62
  };
63
  }
64
  ```
65
 
66
  #### Constructors <a id="mem.poly.allocator.ctor">[[mem.poly.allocator.ctor]]</a>
 
158
  ```
159
 
160
  *Effects:* Equivalent to `deallocate_bytes(p, n*sizeof(T), alignof(T))`.
161
 
162
  ``` cpp
163
+ template<class T, class... CtorArgs>
164
  [[nodiscard]] T* new_object(CtorArgs&&... ctor_args);
165
  ```
166
 
167
  *Effects:* Allocates and constructs an object of type `T`, as follows.
168
  Equivalent to:
 
187
  ```
188
 
189
  *Effects:* Equivalent to:
190
 
191
  ``` cpp
192
+ allocator_traits<polymorphic_allocator>::destroy(*this, p);
193
  deallocate_object(p);
194
  ```
195
 
196
  ``` cpp
197
  template<class T, class... Args>
 
206
  represented by `p` by uses-allocator construction with allocator `*this`
207
  and constructor arguments `std::forward<Args>(args)...`.
208
 
209
  *Throws:* Nothing unless the constructor for `T` throws.
210
 
 
 
 
 
 
 
 
211
  ``` cpp
212
  polymorphic_allocator select_on_container_copy_construction() const;
213
  ```
214
 
215
  *Returns:* `polymorphic_allocator()`.