forked from cplusplus/fundamentals-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmemory.html
2016 lines (1606 loc) · 94.2 KB
/
memory.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<cxx-clause id="memory">
<h1>Memory</h1>
<cxx-section id="header.memory.synop">
<h1>Header <experimental/memory> synopsis</h1>
<pre><code>#include <memory>
namespace std {
namespace experimental {
inline namespace fundamentals_v2 {
// See <cxx-ref in="cxx" to="allocator.uses"></cxx-ref>, uses_allocator
template <class T, class Alloc> constexpr bool uses_allocator_v
= uses_allocator<T, Alloc>::value;
<cxx-ref insynopsis="" to="memory.smartptr.shared"></cxx-ref>
template<class T> class shared_ptr;
// <cxx-ref in="cxx" to="util.smartptr.shared.create"></cxx-ref>
template<class T, class... Args> shared_ptr<T> make_shared(Args&&... args);
template<class T, class A, class... Args>
shared_ptr<T> allocate_shared(const A& a, Args&&... args);
// <cxx-ref in="cxx" to="util.smartptr.shared.cmp"></cxx-ref>
template<class T, class U>
bool operator==(const shared_ptr<T>& a, const shared_ptr<U>& b) noexcept;
template<class T, class U>
bool operator!=(const shared_ptr<T>& a, const shared_ptr<U>& b) noexcept;
template<class T, class U>
bool operator<(const shared_ptr<T>& a, const shared_ptr<U>& b) noexcept;
template<class T, class U>
bool operator>(const shared_ptr<T>& a, const shared_ptr<U>& b) noexcept;
template<class T, class U>
bool operator<=(const shared_ptr<T>& a, const shared_ptr<U>& b) noexcept;
template<class T, class U>
bool operator>=(const shared_ptr<T>& a, const shared_ptr<U>& b) noexcept;
template <class T>
bool operator==(const shared_ptr<T>& a, nullptr_t) noexcept;
template <class T>
bool operator==(nullptr_t, const shared_ptr<T>& b) noexcept;
template <class T>
bool operator!=(const shared_ptr<T>& a, nullptr_t) noexcept;
template <class T>
bool operator!=(nullptr_t, const shared_ptr<T>& b) noexcept;
template <class T>
bool operator<(const shared_ptr<T>& a, nullptr_t) noexcept;
template <class T>
bool operator<(nullptr_t, const shared_ptr<T>& b) noexcept;
template <class T>
bool operator<=(const shared_ptr<T>& a, nullptr_t) noexcept;
template <class T>
bool operator<=(nullptr_t, const shared_ptr<T>& b) noexcept;
template <class T>
bool operator>(const shared_ptr<T>& a, nullptr_t) noexcept;
template <class T>
bool operator>(nullptr_t, const shared_ptr<T>& b) noexcept;
template <class T>
bool operator>=(const shared_ptr<T>& a, nullptr_t) noexcept;
template <class T>
bool operator>=(nullptr_t, const shared_ptr<T>& b) noexcept;
// <cxx-ref in="cxx" to="util.smartptr.shared.spec"></cxx-ref>
template<class T> void swap(shared_ptr<T>& a, shared_ptr<T>& b) noexcept;
<cxx-ref insynopsis="" to="memory.smartptr.shared.cast"></cxx-ref>
template<class T, class U>
shared_ptr<T> static_pointer_cast(const shared_ptr<U>& r) noexcept;
template<class T, class U>
shared_ptr<T> dynamic_pointer_cast(const shared_ptr<U>& r) noexcept;
template<class T, class U>
shared_ptr<T> const_pointer_cast(const shared_ptr<U>& r) noexcept;
template<class T, class U>
shared_ptr<T> reinterpret_pointer_cast(const shared_ptr<U>& r) noexcept;
// <cxx-ref in="cxx" to="util.smartptr.getdeleter"></cxx-ref>
template<class D, class T> D* get_deleter(const shared_ptr<T>& p) noexcept;
// <cxx-ref in="cxx" to="util.smartptr.shared.io"></cxx-ref>
template<class E, class T, class Y>
basic_ostream<E, T>& operator<< (basic_ostream<E, T>& os, const shared_ptr<Y>& p);
<cxx-ref insynopsis="" to="memory.smartptr.weak"></cxx-ref>
template<class T> class weak_ptr;
// <cxx-ref in="cxx" to="util.smartptr.weak.spec"></cxx-ref>
template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept;
// <cxx-ref in="cxx" to="util.smartptr.ownerless"></cxx-ref>
template<class T> class owner_less;
// <cxx-ref in="cxx" to="util.smartptr.enab"></cxx-ref>
template<class T> class enable_shared_from_this;
// <cxx-ref in="cxx" to="util.smartptr.shared.atomic"></cxx-ref>
template<class T>
bool atomic_is_lock_free(const shared_ptr<T>* p);
template<class T>
shared_ptr<T> atomic_load(const shared_ptr<T>* p);
template<class T>
shared_ptr<T> atomic_load_explicit(const shared_ptr<T>* p, memory_order mo);
template<class T>
void atomic_store(shared_ptr<T>* p, shared_ptr<T> r);
template<class T>
void atomic_store_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo);
template<class T>
shared_ptr<T> atomic_exchange(shared_ptr<T>* p, shared_ptr<T> r);
template<class T>
shared_ptr<T> atomic_exchange_explicit(shared_ptr<T>* p, shared_ptr<T> r,
memory_order mo);
template<class T>
bool atomic_compare_exchange_weak(
shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w);
template<class T>
bool atomic_compare_exchange_strong(
shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w);
template<class T>
bool atomic_compare_exchange_weak_explicit(
shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w,
memory_order success, memory_order failure);
template<class T>
bool atomic_compare_exchange_strong_explicit(
shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w,
memory_order success, memory_order failure);
<cxx-ref insynopsis to="memory.observer.ptr"></cxx-ref>
template <class W> class observer_ptr;
<cxx-ref insynopsis to="memory.observer.ptr.special"></cxx-ref>
template <class W>
void swap(observer_ptr<W>&, observer_ptr<W>&) noexcept;
template <class W>
observer_ptr<W> make_observer(W*) noexcept;
// (in)equality operators
template <class W1, class W2>
bool operator==(observer_ptr<W1>, observer_ptr<W2>);
template <class W1, class W2>
bool operator!=(observer_ptr<W1>, observer_ptr<W2>);
template <class W>
bool operator==(observer_ptr<W>, nullptr_t) noexcept;
template <class W>
bool operator!=(observer_ptr<W>, nullptr_t) noexcept;
template <class W>
bool operator==(nullptr_t, observer_ptr<W>) noexcept;
template <class W>
bool operator!=(nullptr_t, observer_ptr<W>) noexcept;
// ordering operators
template <class W1, class W2>
bool operator<(observer_ptr<W1>, observer_ptr<W2>);
template <class W1, class W2>
bool operator>(observer_ptr<W1>, observer_ptr<W2>);
template <class W1, class W2>
bool operator<=(observer_ptr<W1>, observer_ptr<W2>);
template <class W1, class W2>
bool operator>=(observer_ptr<W1>, observer_ptr<W2>);
} // inline namespace fundamentals_v2
} // namespace experimental
<cxx-ref insynopsis to="memory.smartptr.shared.hash"></cxx-ref>
template<class T> struct hash<experimental::shared_ptr<T>>;
<cxx-ref insynopsis to="memory.observer.ptr.hash"></cxx-ref>
template <class T> struct hash;
template <class T> struct hash<experimental::observer_ptr<T>>;
} // namespace std</code></pre>
</cxx-section>
<cxx-section id="memory.smartptr">
<h1>Shared-ownership pointers</h1>
<p>
The specification of all declarations within this sub-clause <cxx-ref to="memory.smartptr"></cxx-ref> and its sub-clauses are the same as the corresponding declarations, as specified in <cxx-ref in="cxx" to="util.smartptr"></cxx-ref>, unless explicitly specified otherwise.
</p>
<cxx-section id="memory.smartptr.shared">
<h1>Class template shared_ptr</h1>
<pre><code>
namespace std {
namespace experimental {
inline namespace fundamentals_v2 {
template<class T> class shared_ptr {
public:
typedef remove_extent_t<T> element_type;
<cxx-ref insynopsis="" to="memory.smartptr.shared.const"></cxx-ref>
constexpr shared_ptr() noexcept;
template<class Y> explicit shared_ptr(Y* p);
template<class Y, class D> shared_ptr(Y* p, D d);
template<class Y, class D, class A> shared_ptr(Y* p, D d, A a);
template <class D> shared_ptr(nullptr_t p, D d)
template <class D, class A> shared_ptr(nullptr_t p, D d, A a);
template<class Y> shared_ptr(const shared_ptr<Y>& r, element_type* p) noexcept;
shared_ptr(const shared_ptr& r) noexcept;
template<class Y> shared_ptr(const shared_ptr<Y>& r) noexcept;
shared_ptr(shared_ptr&& r) noexcept;
template<class Y> shared_ptr(shared_ptr<Y>&& r) noexcept;
template<class Y> explicit shared_ptr(const weak_ptr<Y>& r);
template<class Y> shared_ptr(auto_ptr<Y>&& r);
template <class Y, class D> shared_ptr(unique_ptr<Y, D>&& r);
constexpr shared_ptr(nullptr_t) : shared_ptr() { }
// <cxx-ref in="cxx" to="util.smartptr.shared.dest"></cxx-ref>
~shared_ptr();
// <cxx-ref in="cxx" to="util.smartptr.shared.assign"></cxx-ref>
shared_ptr& operator=(const shared_ptr& r) noexcept;
template<class Y> shared_ptr& operator=(const shared_ptr<Y>& r) noexcept;
shared_ptr& operator=(shared_ptr&& r) noexcept;
template<class Y> shared_ptr& operator=(shared_ptr<Y>&& r) noexcept;
template<class Y> shared_ptr& operator=(auto_ptr<Y>&& r);
template <class Y, class D> shared_ptr& operator=(unique_ptr<Y, D>&& r);
// <cxx-ref in="cxx" to="util.smartptr.shared.mod"></cxx-ref>
void swap(shared_ptr& r) noexcept;
void reset() noexcept;
template<class Y> void reset(Y* p);
template<class Y, class D> void reset(Y* p, D d);
template<class Y, class D, class A> void reset(Y* p, D d, A a);
<cxx-ref insynopsis="" to="memory.smartptr.shared.obs"></cxx-ref>
element_type* get() const noexcept;
T& operator*() const noexcept;
T* operator->() const noexcept;
element_type& operator[](ptrdiff_t i) const noexcept;
long use_count() const noexcept;
bool unique() const noexcept;
explicit operator bool() const noexcept;
template<class U> bool owner_before(shared_ptr<U> const& b) const;
template<class U> bool owner_before(weak_ptr<U> const& b) const;
};
// <cxx-ref in="cxx" to="util.smartptr.shared.create"></cxx-ref>
template<class T, class... Args> shared_ptr<T> make_shared(Args&&... args);
template<class T, class A, class... Args>
shared_ptr<T> allocate_shared(const A& a, Args&&... args);
// <cxx-ref in="cxx" to="util.smartptr.shared.cmp"></cxx-ref>
template<class T, class U>
bool operator==(const shared_ptr<T>& a, const shared_ptr<U>& b) noexcept;
template<class T, class U>
bool operator!=(const shared_ptr<T>& a, const shared_ptr<U>& b) noexcept;
template<class T, class U>
bool operator<(const shared_ptr<T>& a, const shared_ptr<U>& b) noexcept;
template<class T, class U>
bool operator>(const shared_ptr<T>& a, const shared_ptr<U>& b) noexcept;
template<class T, class U>
bool operator<=(const shared_ptr<T>& a, const shared_ptr<U>& b) noexcept;
template<class T, class U>
bool operator>=(const shared_ptr<T>& a, const shared_ptr<U>& b) noexcept;
template <class T>
bool operator==(const shared_ptr<T>& a, nullptr_t) noexcept;
template <class T>
bool operator==(nullptr_t, const shared_ptr<T>& b) noexcept;
template <class T>
bool operator!=(const shared_ptr<T>& a, nullptr_t) noexcept;
template <class T>
bool operator!=(nullptr_t, const shared_ptr<T>& b) noexcept;
template <class T>
bool operator<(const shared_ptr<T>& a, nullptr_t) noexcept;
template <class T>
bool operator<(nullptr_t, const shared_ptr<T>& b) noexcept;
template <class T>
bool operator<=(const shared_ptr<T>& a, nullptr_t) noexcept;
template <class T>
bool operator<=(nullptr_t, const shared_ptr<T>& b) noexcept;
template <class T>
bool operator>(const shared_ptr<T>& a, nullptr_t) noexcept;
template <class T>
bool operator>(nullptr_t, const shared_ptr<T>& b) noexcept;
template <class T>
bool operator>=(const shared_ptr<T>& a, nullptr_t) noexcept;
template <class T>
bool operator>=(nullptr_t, const shared_ptr<T>& b) noexcept;
// <cxx-ref in="cxx" to="util.smartptr.shared.spec"></cxx-ref>
template<class T> void swap(shared_ptr<T>& a, shared_ptr<T>& b) noexcept;
<cxx-ref insynopsis="" to="memory.smartptr.shared.cast"></cxx-ref>
template<class T, class U>
shared_ptr<T> static_pointer_cast(const shared_ptr<U>& r) noexcept;
template<class T, class U>
shared_ptr<T> dynamic_pointer_cast(const shared_ptr<U>& r) noexcept;
template<class T, class U>
shared_ptr<T> const_pointer_cast(const shared_ptr<U>& r) noexcept;
template<class T, class U>
shared_ptr<T> reinterpret_pointer_cast(const shared_ptr<U>& r) noexcept;
// <cxx-ref in="cxx" to="util.smartptr.getdeleter"></cxx-ref>
template<class D, class T> D* get_deleter(const shared_ptr<T>& p) noexcept;
// <cxx-ref in="cxx" to="util.smartptr.shared.io"></cxx-ref>
template<class E, class T, class Y>
basic_ostream<E, T>& operator<< (basic_ostream<E, T>& os, const shared_ptr<Y>& p);
// <cxx-ref in="cxx" to="util.smartptr.ownerless"></cxx-ref>
template<class T> class owner_less;
// <cxx-ref in="cxx" to="util.smartptr.enab"></cxx-ref>
template<class T> class enable_shared_from_this;
// <cxx-ref in="cxx" to="util.smartptr.shared.atomic"></cxx-ref>
template<class T>
bool atomic_is_lock_free(const shared_ptr<T>* p);
template<class T>
shared_ptr<T> atomic_load(const shared_ptr<T>* p);
template<class T>
shared_ptr<T> atomic_load_explicit(const shared_ptr<T>* p, memory_order mo);
template<class T>
void atomic_store(shared_ptr<T>* p, shared_ptr<T> r);
template<class T>
void atomic_store_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo);
template<class T>
shared_ptr<T> atomic_exchange(shared_ptr<T>* p, shared_ptr<T> r);
template<class T>
shared_ptr<T> atomic_exchange_explicit(shared_ptr<T>* p, shared_ptr<T> r,
memory_order mo);
template<class T>
bool atomic_compare_exchange_weak(
shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w);
template<class T>
bool atomic_compare_exchange_strong(
shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w);
template<class T>
bool atomic_compare_exchange_weak_explicit(
shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w,
memory_order success, memory_order failure);
template<class T>
bool atomic_compare_exchange_strong_explicit(
shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w,
memory_order success, memory_order failure);
} // namespace fundamentals_v2
} // namespace experimental
<cxx-ref insynopsis to="memory.smartptr.shared.hash"></cxx-ref>
template<class T> struct hash<experimental::shared_ptr<T>>;
} // namespace std</code></pre>
<p>
For the purposes of subclause <cxx-ref to="memory.smartptr"></cxx-ref>, a pointer type <code>Y*</code> is said to be <dfn>compatible with</dfn> a pointer type <code>T*</code> when either <code>Y*</code> is convertible to <code>T*</code> or <code>Y</code> is <code>U[N]</code> and <code>T</code> is <code>U <var>cv</var> []</code>.
</p>
<cxx-section id="memory.smartptr.shared.const">
<h1><code>shared_ptr</code> constructors</h1>
<cxx-function>
<cxx-signature>template<class Y> explicit shared_ptr(Y* p);</cxx-signature>
<cxx-requires><code>Y</code> shall be a complete type.
The expression <code>delete[] p</code>, when <code>T</code> is an array type,
or <code>delete p</code>, when <code>T</code> is not an array type,
shall be well-formed, shall have well defined behavior, and shall not throw exceptions.
When <code>T</code> is <code>U[N]</code>, <code>Y(*)[N]</code> shall be convertible to <code>T*</code>;
when <code>T</code> is <code>U[]</code>, <code>Y(*)[]</code> shall be convertible to <code>T*</code>;
otherwise, <code>Y*</code> shall be convertible to <code>T*</code>.</cxx-requires>
<cxx-effects>When <code>T</code> is not an array type, constructs a <code>shared_ptr</code> object that <i>owns</i> the pointer <code>p</code>.
Otherwise, constructs a <code>shared_ptr</code> that <em>owns</em> <code>p</code> and a deleter of an unspecified type that calls <code>delete[] p</code>.
If an exception is thrown, <code>delete p</code> is called when <code>T</code> is not an array type, <code>delete[] p</code> otherwise.</cxx-effects>
<cxx-postconditions><code>use_count() == 1 && get() == p</code>.</cxx-postconditions>
<cxx-throws><code>bad_alloc</code>, or an implementation-defined exception when a resource other than memory could not be obtained.</cxx-throws>
</cxx-function>
<cxx-function>
<cxx-signature>template<class Y, class D> shared_ptr(Y* p, D d);</cxx-signature>
<cxx-signature>template<class Y, class D, class A> shared_ptr(Y* p, D d, A a);</cxx-signature>
<cxx-signature>template <class D> shared_ptr(nullptr_t p, D d);</cxx-signature>
<cxx-signature>template <class D, class A> shared_ptr(nullptr_t p, D d, A a);</cxx-signature>
<cxx-requires><code>D</code> shall be <code>CopyConstructible</code>. The copy constructor and destructor of <code> D</code> shall not throw exceptions. The expression <code>d(p)</code> shall be well formed, shall have well defined behavior, and shall not throw exceptions. <code>A</code> shall be an allocator (<cxx-ref in="cxx" to="allocator.requirements"></cxx-ref>). The copy constructor and destructor of <code>A</code> shall not throw exceptions.
When <code>T</code> is <code>U[N]</code>, <code>Y(*)[N]</code> shall be convertible to <code>T*</code>;
when <code>T</code> is <code>U[]</code>, <code>Y(*)[]</code> shall be convertible to <code>T*</code>;
otherwise, <code>Y*</code> shall be convertible to <code>T*</code>.</cxx-requires>
<cxx-effects>Constructs a <code>shared_ptr</code> object that <i>owns</i> the object <code>p</code> and the deleter <code>d</code>. The second and fourth constructors shall use a copy of <code>a</code> to allocate memory for internal use. If an exception is thrown, <code>d(p)</code> is called.</cxx-effects>
<cxx-postconditions><code>use_count() == 1 && get() == p</code>.</cxx-postconditions>
<cxx-throws><code>bad_alloc</code>, or an implementation-defined exception when a resource other than memory could not be obtained.</cxx-throws>
</cxx-function>
<cxx-function>
<cxx-signature>template<class Y> shared_ptr(const shared_ptr<Y>& r, element_type* p) noexcept;</cxx-signature>
<cxx-effects>Constructs a <code>shared_ptr</code> instance that stores <code>p</code> and <i>shares ownership</i> with <code>r</code>.</cxx-effects>
<cxx-postconditions><code>get() == p && use_count() == r.use_count()</code>.</cxx-postconditions>
<p>
<cxx-note>To avoid the possibility of a dangling pointer, the user of this constructor must ensure that <code>p</code> remains valid at least until the ownership group of <code>r</code> is destroyed.</cxx-note>
</p>
<p>
<cxx-note>This constructor allows creation of an <i>empty</i> <code>shared_ptr</code> instance with a non-null stored pointer.</cxx-note>
</p>
</cxx-function>
<cxx-function>
<cxx-signature>shared_ptr(const shared_ptr& r) noexcept;</cxx-signature>
<cxx-signature>template<class Y> shared_ptr(const shared_ptr<Y>& r) noexcept;</cxx-signature>
<cxx-requires> The second constructor shall not participate in the overload resolution unless <code>Y*</code> is <i>compatible with</i> <code>T*</code>.</cxx-requires>
<cxx-effects>If <code>r</code> is <i>empty</i>, constructs an <i>empty</i> <code>shared_ptr</code> object; otherwise, constructs a <code>shared_ptr</code> object that <i>shares ownership</i> with <code>r</code>.</cxx-effects>
<cxx-postconditions><code>get() == r.get() && use_count() == r.use_count()</code>.</cxx-postconditions>
</cxx-function>
<cxx-function>
<cxx-signature>shared_ptr(shared_ptr&& r) noexcept;</cxx-signature>
<cxx-signature>template<class Y> shared_ptr(shared_ptr<Y>&& r) noexcept;</cxx-signature>
<cxx-ednote>N3920 specifies that "implicitly convertible" is removed, but the C++14 draft only has "convertible". Does this make a difference?</cxx-ednote>
<cxx-remarks>The second constructor shall not participate in overload resolution unless <code>Y*</code> is <i>compatible with</i> <code>T*</code>.</cxx-remarks>
<cxx-effects>Move-constructs a <code>shared_ptr</code> instance from <code>r</code>.</cxx-effects>
<cxx-postconditions><code>*this</code> shall contain the old value of <code>r</code>. <code>r</code> shall be <i>empty</i>. <code>r.get() == 0.</code></cxx-postconditions>
</cxx-function>
<cxx-function>
<cxx-signature>template<class Y> explicit shared_ptr(const weak_ptr<Y>& r);</cxx-signature>
<cxx-requires><code>Y*</code> shall be <i>compatible with</i> <code>T*</code>.</cxx-requires>
<cxx-effects>Constructs a <code>shared_ptr</code> object that <i>shares ownership</i> with <code>r</code> and stores a copy of the pointer stored in <code>r</code>. If an exception is thrown, the constructor has no effect.</cxx-effects>
<cxx-postconditions><code>use_count() == r.use_count()</code>.</cxx-postconditions>
<cxx-throws><code>bad_weak_ptr</code> when <code>r.expired()</code>.</cxx-throws>
</cxx-function>
<cxx-function>
<cxx-signature>template <class Y, class D> shared_ptr(unique_ptr<Y, D>&& r);</cxx-signature>
<cxx-remarks>This constructor shall not participate in overload resolution unless <code>Y*</code> is <em>compatible with</em> <code>T*</code>.</cxx-remarks>
<cxx-effects>Equivalent to <code>shared_ptr(r.release(), r.get_deleter())</code> when <code>D</code> is not a reference type, otherwise <code>shared_ptr(r.release(), ref(r.get_deleter()))</code>. If an exception is thrown, the constructor has no effect.</cxx-effects>
</cxx-function>
</cxx-section>
<cxx-section id="memory.smartptr.shared.obs">
<h1><code>shared_ptr</code> observers</h1>
<cxx-function>
<cxx-signature>element_type* get() const noexcept;</cxx-signature>
<cxx-returns>The stored pointer.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>T& operator*() const noexcept;</cxx-signature>
<cxx-requires><code>get() != 0</code>.</cxx-requires>
<cxx-returns><code>*get()</code>.</cxx-returns>
<cxx-remarks>When <code>T</code> is an array type or (possibly cv-qualified) <code>void</code>, it is unspecified whether this member function is declared. If it is declared, it is unspecified what its return type is, except that the declaration (although not necessarily the definition) of the function shall be well formed.</cxx-remarks>
</cxx-function>
<cxx-function>
<cxx-signature>T* operator->() const noexcept;</cxx-signature>
<cxx-requires><code>get() != 0</code>.</cxx-requires>
<cxx-returns><code>get()</code>.</cxx-returns>
<cxx-remarks>When <code>T</code> is an array type, it is unspecified whether this member function is declared.
If it is declared, it is unspecified what its return type is, except that the declaration (although not necessarily the definition) of the function shall be well formed.</cxx-remarks>
</cxx-function>
<cxx-function>
<cxx-signature>element_type& operator[](ptrdiff_t i) const noexcept;</cxx-signature>
<cxx-requires><code>get() != 0 && i >= 0</code>. If <code>T</code> is <code>U[N]</code>, <code>i < N</code>.</cxx-requires>
<cxx-returns><code>get()[i]</code>.</cxx-returns>
<cxx-remarks>When <code>T</code> is not an array type, it is unspecified whether this member function is declared.
If it is declared, it is unspecified what its return type is, except that the declaration (although not necessarily the definition) of the function shall be well formed.</cxx-remarks>
</cxx-function>
</cxx-section>
<cxx-section id="memory.smartptr.shared.cast">
<h1><code>shared_ptr</code> casts</h1>
<cxx-function>
<cxx-signature>template<class T, class U> shared_ptr<T> static_pointer_cast(const shared_ptr<U>& r) noexcept;</cxx-signature>
<cxx-requires>The expression <code>static_cast<T*>((U*)0)</code> shall be well formed.</cxx-requires>
<cxx-returns><code>shared_ptr<T>(r, static_cast<typename shared_ptr<T>::element_type*>(r.get()))</code>.</cxx-returns>
<p>
<cxx-note>The seemingly equivalent expression <code>shared_ptr<T>(static_cast<T*>(r.get()))</code> will eventually result in undefined behavior, attempting to delete the same object twice.</cxx-note>
</p>
</cxx-function>
<cxx-function>
<cxx-signature>template<class T, class U> shared_ptr<T> dynamic_pointer_cast(const shared_ptr<U>& r) noexcept;</cxx-signature>
<cxx-requires>The expression <code>dynamic_cast<T*>((U*)0)</code> shall be well formed.</cxx-requires>
<cxx-returns>
<ul>
<li>When <code>dynamic_cast<typename shared_ptr<T>::element_type*>(r.get())</code> returns a nonzero value <code>p</code>, <code>shared_ptr<T>(r, p)</code>;</li>
<li>Otherwise, <code>shared_ptr<T>()</code>.</li>
</ul>
</cxx-returns>
<p>
<cxx-note>The seemingly equivalent expression <code>shared_ptr<T>(dynamic_cast<T*>(r.get()))</code> will eventually result in undefined behavior, attempting to delete the same object twice.</cxx-note>
</p>
</cxx-function>
<cxx-function>
<cxx-signature>template<class T, class U> shared_ptr<T> const_pointer_cast(const shared_ptr<U>& r) noexcept;</cxx-signature>
<cxx-requires>The expression <code>const_cast<T*>((U*)0)</code> shall be well formed.</cxx-requires>
<cxx-returns><code>shared_ptr<T>(r, const_cast<typename shared_ptr<T>::element_type*>(r.get()))</code>.</cxx-returns>
<p>
<cxx-note>The seemingly equivalent expression <code>shared_ptr<T>(const_cast<T*>(r.get()))</code> will eventually result in undefined behavior, attempting to delete the same object twice.</cxx-note>
</p>
</cxx-function>
<cxx-function>
<cxx-signature>template<class T, class U> shared_ptr<T> reinterpret_pointer_cast(const shared_ptr<U>& r) noexcept;</cxx-signature>
<cxx-requires>The expression <code>reinterpret_cast<T*>((U*)0)</code> shall be well formed.</cxx-requires>
<cxx-returns><code>shared_ptr<T>(r, reinterpret_cast<typename shared_ptr<T>::element_type*>(r.get()))</code>.</cxx-returns>
</cxx-function>
</cxx-section>
<cxx-section id="memory.smartptr.shared.hash">
<h1><code>shared_ptr</code> hash support</h1>
<cxx-function>
<cxx-signature>template <class T> struct hash<experimental::shared_ptr<T>>;</cxx-signature>
<p>The template specialization shall meet the requirements of class template <code>hash</code> (<cxx-ref in="cxx" to="unord.hash"></cxx-ref>). For an object <code>p</code> of type <code>experimental::shared_ptr<T></code>, <code>hash<experimental::shared_ptr<T>>()(p)</code> shall evaluate to the same value as <code>hash<typename experimental::shared_ptr<T>::element_type*>()(p.get())</code>.</p>
</cxx-section>
</cxx-section>
<cxx-section id="memory.smartptr.weak">
<h1>Class template weak_ptr</h1>
<pre><code>
namespace std {
namespace experimental {
inline namespace fundamentals_v2 {
template<class T> class weak_ptr {
public:
typedef remove_extent_t<T> element_type;
<cxx-ref insynopsis="" to="memory.smartptr.weak.const"></cxx-ref>
constexpr weak_ptr() noexcept;
template<class Y> weak_ptr(shared_ptr<Y> const& r) noexcept;
weak_ptr(weak_ptr const& r) noexcept;
template<class Y> weak_ptr(weak_ptr<Y> const& r) noexcept;
weak_ptr(weak_ptr&& r) noexcept;
template<class Y> weak_ptr(weak_ptr<Y>&& r) noexcept;
// <cxx-ref in="cxx" to="util.smartptr.weak.dest"></cxx-ref>
~weak_ptr();
// <cxx-ref in="cxx" to="util.smartptr.weak.assign"></cxx-ref>
weak_ptr& operator=(weak_ptr const& r) noexcept;
template<class Y> weak_ptr& operator=(weak_ptr<Y> const& r) noexcept;
template<class Y> weak_ptr& operator=(shared_ptr<Y> const& r) noexcept;
weak_ptr& operator=(weak_ptr&& r) noexcept;
template<class Y> weak_ptr& operator=(weak_ptr<Y>&& r) noexcept;
// <cxx-ref in="cxx" to="util.smartptr.weak.mod"></cxx-ref>
void swap(weak_ptr& r) noexcept;
void reset() noexcept;
// <cxx-ref in="cxx" to="util.smartptr.weak.obs"></cxx-ref>
long use_count() const noexcept;
bool expired() const noexcept;
shared_ptr<T> lock() const noexcept;
template<class U> bool owner_before(shared_ptr<U> const& b) const;
template<class U> bool owner_before(weak_ptr<U> const& b) const;
};
// <cxx-ref in="cxx" to="util.smartptr.weak.spec"></cxx-ref>
template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept;
} // namespace fundamentals_v2
} // namespace experimental
} // namespace std</code></pre>
<cxx-section id="memory.smartptr.weak.const">
<h1><code>weak_ptr</code> constructors</h1>
<cxx-function>
<cxx-signature>weak_ptr(const weak_ptr& r) noexcept;</cxx-signature>
<cxx-signature>template<class Y> weak_ptr(const weak_ptr<Y>& r) noexcept;</cxx-signature>
<cxx-signature>template<class Y> weak_ptr(const shared_ptr<Y>& r) noexcept;</cxx-signature>
<cxx-requires>The second and third constructors shall not participate in the overload resolution unless <code>Y*</code> is <i>compatible with</i> <code>T*</code>.</cxx-requires>
<cxx-effects>If <code>r</code> is <i>empty</i>, constructs an <i>empty</i> <code>weak_ptr</code> object; otherwise, constructs a <code>weak_ptr</code> object that <i>shares ownership</i> with <code>r</code> and stores a copy of the pointer stored in <code>r</code>.</cxx-effects>
<cxx-postconditions><code>use_count() == r.use_count()</code>.</cxx-postconditions>
</cxx-function>
</cxx-section>
</cxx-section>
</cxx-section>
<cxx-section id="memory.type.erased.allocator">
<h1>Type-erased allocator</h1>
<p>
A <dfn>type-erased allocator</dfn> is an allocator or memory resource, <code>alloc</code>,
used to allocate internal data structures for an object <code>X</code> of type <code>C</code>,
but where <code>C</code> is not dependent on the type of <code>alloc</code>.
Once <code>alloc</code> has been supplied to <code>X</code> (typically as a constructor argument),
<code>alloc</code> can be retrieved from <code>X</code> only as a pointer <code>rptr</code> of static type <code>std::experimental::pmr::memory_resource*</code> (<cxx-ref to="memory.resource"></cxx-ref>).
The process by which <code>rptr</code> is computed from <code>alloc</code> depends on the type of <code>alloc</code> as described in <cxx-ref to="tab:memory.resource.type.erased.allocator"></cxx-ref>:
</p>
<table is="cxx-table" id="tab:memory.resource.type.erased.allocator">
<caption>Computed <code>memory_resource</code> for type-erased allocator</caption>
<thead>
<tr>
<th>If the type of <code>alloc</code> is</th>
<th>then the value of <code>rptr</code> is</th>
</tr>
</thead>
<tr>
<td>non-existent — no <code>alloc</code> specified</td>
<td>The value of <code>experimental::pmr::get_default_resource()</code> at the time of construction.</td>
</tr>
<tr>
<td><code>nullptr_t</code></td>
<td>The value of <code>experimental::pmr::get_default_resource()</code> at the time of construction.</td>
</tr>
<tr>
<td>a pointer type convertible to <code>pmr::memory_resource*</code></td>
<td><code>static_cast<experimental::pmr::memory_resource*>(alloc)</code></td>
</tr>
<tr>
<td><code>pmr::polymorphic_allocator<U></code></td>
<td><code>alloc.resource()</code></td>
</tr>
<tr>
<td>any other type meeting the Allocator requirements (<cxx-ref in="cxx" to="allocator.requirements"></cxx-ref>)</td>
<td>a pointer to a value of type <code>experimental::pmr::resource_adaptor<A></code> where <code>A</code> is the type of <code>alloc</code>.
<code>rptr</code> remains valid only for the lifetime of <code>X</code>.</td>
</tr>
<tr>
<td>None of the above</td>
<td>The program is ill-formed.</td>
</tr>
</table>
<p>Additionally, class <code>C</code> shall meet the following requirements:</p>
<ul>
<li><code>C::allocator_type</code> shall be identical to <code>std::experimental::erased_type</code>.</li>
<li><code>X.get_memory_resource()</code> returns <code>rptr</code>.</li>
</ul>
</cxx-section>
<cxx-section id="memory.resource.synop">
<h1>Header <code><experimental/memory_resource></code> synopsis</h1>
<pre><code>namespace std {
namespace experimental {
inline namespace fundamentals_v2 {
namespace pmr {
class memory_resource;
bool operator==(const memory_resource& a,
const memory_resource& b) noexcept;
bool operator!=(const memory_resource& a,
const memory_resource& b) noexcept;
template <class Tp> class polymorphic_allocator;
template <class T1, class T2>
bool operator==(const polymorphic_allocator<T1>& a,
const polymorphic_allocator<T2>& b) noexcept;
template <class T1, class T2>
bool operator!=(const polymorphic_allocator<T1>& a,
const polymorphic_allocator<T2>& b) noexcept;
// The name <var>resource_adaptor_imp</var> is for exposition only.
template <class Allocator> class <var>resource_adaptor_imp</var>;
template <class Allocator>
using resource_adaptor = <var>resource_adaptor_imp</var><
typename allocator_traits<Allocator>::template rebind_alloc<char>>;
// Global memory resources
memory_resource* new_delete_resource() noexcept;
memory_resource* null_memory_resource() noexcept;
// The default memory resource
memory_resource* set_default_resource(memory_resource* r) noexcept;
memory_resource* get_default_resource() noexcept;
// Standard memory resources
struct pool_options;
class synchronized_pool_resource;
class unsynchronized_pool_resource;
class monotonic_buffer_resource;
} // namespace pmr
} // namespace fundamentals_v2
} // namespace experimental
} // namespace std</code></pre>
</cxx-section>
<cxx-section id="memory.resource">
<h1>Class <code>memory_resource</code></h1>
<cxx-section id="memory.resource.overview">
<h1>Class <code>memory_resource</code> overview</h1>
<p>
The <code>memory_resource</code> class is an abstract interface to an unbounded set of classes encapsulating memory resources.
</p>
<pre><code>class memory_resource {
// For exposition only
static constexpr size_t max_align = alignof(max_align_t);
public:
virtual ~memory_resource();
void* allocate(size_t bytes, size_t alignment = max_align);
void deallocate(void* p, size_t bytes,
size_t alignment = max_align);
bool is_equal(const memory_resource& other) const noexcept;
protected:
virtual void* do_allocate(size_t bytes, size_t alignment) = 0;
virtual void do_deallocate(void* p, size_t bytes,
size_t alignment) = 0;
virtual bool do_is_equal(const memory_resource& other) const noexcept = 0;
};</code></pre>
</cxx-section>
<cxx-section id="memory.resource.public">
<h1><code>memory_resource</code> public member functions</h1>
<cxx-function>
<cxx-signature>~memory_resource();</cxx-signature>
<cxx-effects>Destroys this memory_resource.</cxx-effects>
</cxx-function>
<cxx-function>
<cxx-signature>void* allocate(size_t bytes, size_t alignment = max_align);</cxx-signature>
<cxx-effects>Equivalent to <code>return do_allocate(bytes, alignment);</code></cxx-effects>
</cxx-function>
<cxx-function>
<cxx-signature>void deallocate(void* p, size_t bytes, size_t alignment = max_align);</cxx-signature>
<cxx-effects>Equivalent to <code>do_deallocate(p, bytes, alignment);</code></cxx-effects>
</cxx-function>
<cxx-function>
<cxx-signature>bool is_equal(const memory_resource& other) const noexcept;</cxx-signature>
<cxx-effects>Equivalent to <code>return do_is_equal(other);</code></cxx-effects>
</cxx-function>
</cxx-section>
<cxx-section id="memory.resource.priv">
<h1><code>memory_resource</code> protected virtual member functions</h1>
<cxx-function>
<cxx-signature>virtual void* do_allocate(size_t bytes, size_t alignment) = 0;</cxx-signature>
<cxx-requires>Alignment shall be a power of two.</cxx-requires>
<cxx-returns>A derived class shall implement this function to return a pointer to allocated storage (<cxx-ref in="cxx" to="basic.stc.dynamic.deallocation"></cxx-ref>) with a size of at least <code>bytes</code>.
The returned storage is aligned to the specified alignment, if such alignment is supported;
otherwise it is aligned to <code>max_align</code>.</cxx-returns>
<cxx-throws>A derived class implementation shall throw an appropriate exception if it is unable to allocate memory with the requested size and alignment.</cxx-throws>
</cxx-function>
<cxx-function>
<cxx-signature>virtual void do_deallocate(void* p, size_t bytes, size_t alignment) = 0;</cxx-signature>
<cxx-requires><code>p</code> shall have been returned from a prior call to <code>allocate(bytes, alignment)</code> on a memory resource equal to <code>*this</code>,
and the storage at <code>p</code> shall not yet have been deallocated.</cxx-requires>
<cxx-effects>A derived class shall implement this function to dispose of allocated storage.</cxx-effects>
<cxx-throws>Nothing.</cxx-throws>
</cxx-function>
<cxx-function>
<cxx-signature>virtual bool do_is_equal(const memory_resource& other) const noexcept = 0;</cxx-signature>
<cxx-returns>A derived class shall implement this function to return <code>true</code> if memory allocated from this can be deallocated from other and vice-versa;
otherwise it shall return false.
<cxx-note>The most-derived type of other might not match the type of this.
For a derived class, D, a typical implementation of this function will compute <code>dynamic_cast<const D*>(&other)</code> and go no further (i.e., return <code>false</code>) if it returns <code>nullptr</code>.</cxx-note></cxx-returns>
</cxx-function>
</cxx-section>
<cxx-section id="memory.resource.eq">
<h1><code>memory_resource</code> equality</h1>
<cxx-function>
<cxx-signature>bool operator==(const memory_resource& a, const memory_resource& b) noexcept;</cxx-signature>
<cxx-returns><code>&a == &b || a.is_equal(b)</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>bool operator!=(const memory_resource& a, const memory_resource& b) noexcept;</cxx-signature>
<cxx-returns><code>!(a == b)</code>.</cxx-returns>
</cxx-function>
</cxx-section>
</cxx-section>
<cxx-section id="memory.polymorphic.allocator.class">
<h1>Class template <code>polymorphic_allocator</code></h1>
<cxx-section id="memory.polymorphic.allocator.overview">
<h1>Class template <code>polymorphic_allocator</code> overview</h1>
<p>
A specialization of class template <code>pmr::polymorphic_allocator</code> conforms to the <code>Allocator</code> requirements (<cxx-ref in="cxx" to="allocator.requirements"></cxx-ref>).
Constructed with different memory resources, different instances of the same specialization of <code>pmr::polymorphic_allocator</code> can exhibit entirely different allocation behavior.
This runtime polymorphism allows objects that use <code>polymorphic_allocator</code> to behave as if they used different allocator types at run time even though they use the same static allocator type.
</p>
<pre><code>template <class Tp>
class polymorphic_allocator {
memory_resource* m_resource; // For exposition only
public:
typedef Tp value_type;
polymorphic_allocator() noexcept;
polymorphic_allocator(memory_resource* r);
polymorphic_allocator(const polymorphic_allocator& other) = default;
template <class U>
polymorphic_allocator(const polymorphic_allocator<U>& other) noexcept;
polymorphic_allocator&
operator=(const polymorphic_allocator& rhs) = default;
Tp* allocate(size_t n);
void deallocate(Tp* p, size_t n);
template <class T, class... Args>
void construct(T* p, Args&&... args);
// Specializations for pair using piecewise construction
template <class T1, class T2, class... Args1, class... Args2>
void construct(pair<T1,T2>* p, piecewise_construct_t,
tuple<Args1...> x, tuple<Args2...> y);
template <class T1, class T2>
void construct(pair<T1,T2>* p);
template <class T1, class T2, class U, class V>
void construct(pair<T1,T2>* p, U&& x, V&& y);
template <class T1, class T2, class U, class V>
void construct(pair<T1,T2>* p, const std::pair<U, V>& pr);
template <class T1, class T2, class U, class V>
void construct(pair<T1,T2>* p, pair<U, V>&& pr);
template <class T>
void destroy(T* p);
// Return a default-constructed allocator (no allocator propagation)
polymorphic_allocator select_on_container_copy_construction() const;
memory_resource* resource() const;
};</code></pre>
</cxx-section>
<cxx-section id="memory.polymorphic.allocator.ctor">
<h1><code>polymorphic_allocator</code> constructors</h1>
<cxx-function>
<cxx-signature>polymorphic_allocator() noexcept;</cxx-signature>
<cxx-effects>Sets <code>m_resource</code> to <code>get_default_resource()</code>.</cxx-effects>
</cxx-function>
<cxx-function>
<cxx-signature>polymorphic_allocator(memory_resource* r);</cxx-signature>
<cxx-requires><code>r</code> is non-null.</cxx-requires>
<cxx-effects>Sets <code>m_resource</code> to <code>r</code>.</cxx-effects>
<cxx-throws>Nothing.</cxx-throws>
<cxx-notes>This constructor provides an implicit conversion from <code>memory_resource*</code>.</cxx-notes>
</cxx-function>
<cxx-function>
<cxx-signature>template <class U>
polymorphic_allocator(const polymorphic_allocator<U>& other) noexcept;</cxx-signature>
<cxx-effects>Sets <code>m_resource</code> to <code>other.resource()</code>.</cxx-effects>
</cxx-function>
</cxx-section>
<cxx-section id="memory.polymorphic.allocator.mem">
<h1><code>polymorphic_allocator</code> member functions</h1>
<cxx-function>
<cxx-signature>Tp* allocate(size_t n);</cxx-signature>
<cxx-returns>Equivalent to <code>return static_cast<Tp*>(m_resource->allocate(n * sizeof(Tp), alignof(Tp)));</code></cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>void deallocate(Tp* p, size_t n);</cxx-signature>
<cxx-requires><code>p</code> was allocated from a memory resource, <code>x</code>, equal to <code>*m_resource</code>, using <code>x.allocate(n * sizeof(Tp), alignof(Tp))</code>.</cxx-requires>
<cxx-effects>Equivalent to <code>m_resource->deallocate(p, n * sizeof(Tp), alignof(Tp))</code>.</cxx-effects>
<cxx-throws>Nothing.</cxx-throws>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T, class... Args>
void construct(T* p, Args&&... args);</cxx-signature>
<cxx-requires><cxx-term>Uses-allocator construction</cxx-term> of <code>T</code>
with allocator <code>this->resource()</code> (see <cxx-ref to="mods.allocator.uses"></cxx-ref>)
and constructor arguments <code>std::forward<Args>(args)...</code> is well-formed.
<cxx-note><cxx-term>uses-allocator construction</cxx-term> is always well formed for types that do not use allocators.</cxx-note></cxx-requires>
<cxx-effects>Construct a <code>T</code> object at <code>p</code> by <cxx-term>uses-allocator construction</cxx-term>
with allocator <code>this->resource()</code> (<cxx-ref to="mods.allocator.uses"></cxx-ref>)
and constructor arguments <code>std::forward<Args>(args)...</code>.</cxx-effects>
<cxx-throws>Nothing unless the constructor for <code>T</code> throws.</cxx-throws>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T1, class T2, class... Args1, class... Args2>
void construct(pair<T1,T2>* p, piecewise_construct_t,
tuple<Args1...> x, tuple<Args2...> y);</cxx-signature>
<cxx-effects>
Let <code>xprime</code> be a <code>tuple</code> constructed from <code>x</code> according to the appropriate rule from the following list.
<cxx-note>The following description can be summarized as constructing a <code>std::pair<T1,T2></code> object at <code>p</code>
as if by separate <i>uses-allocator construction</i> with allocator <code>this->resource()</code> (<cxx-ref to="mods.allocator.uses"></cxx-ref>)
of <code>p->first</code> using the elements of <code>x</code>
and <code>p->second</code> using the elements of <code>y</code>.</cxx-note>
<ul>
<li>If <code>uses_allocator_v<T1,memory_resource*></code> is <code>false</code> and
<code>is_constructible_v<T,Args1...></code> is <code>true</code>, then <code>xprime</code> is <code>x</code>.</li>
<li>Otherwise, if <code>uses_allocator_v<T1,memory_resource*></code> is <code>true</code> and
<code>is_constructible_v<T1,allocator_arg_t,memory_resource*,Args1...></code> is <code>true</code>,
then <code>xprime</code> is <code>tuple_cat(make_tuple(allocator_arg, this->resource()), std::move(x))</code>.</li>
<li>Otherwise, if <code>uses_allocator_v<T1,memory_resource*></code> is <code>true</code> and
<code>is_constructible_v<T1,Args1...,memory_resource*></code> is <code>true</code>,
then <code>xprime</code> is <code>tuple_cat(std::move(x), make_tuple(this->resource()))</code>.</li>
<li>Otherwise the program is ill formed.</li>
</ul>
and let <code>yprime</code> be a tuple constructed from <code>y</code>
according to the appropriate rule from the following list:
<ul>
<li>If <code>uses_allocator_v<T2,memory_resource*></code> is <code>false</code> and
<code>is_constructible_v<T,Args2...></code> is <code>true</code>, then <code>yprime</code> is <code>y</code>.</li>
<li>Otherwise, if <code>uses_allocator_v<T2,memory_resource*></code> is <code>true</code> and
<code>is_constructible_v<T2,allocator_arg_t,memory_resource*,Args2...></code> is <code>true</code>, then <code>yprime</code> is <code>tuple_cat(make_tuple(allocator_arg, this->resource()), std::move(y))</code>.</li>
<li>Otherwise, if <code>uses_allocator_v<T2,memory_resource*></code> is <code>true</code> and
<code>is_constructible_v<T2,Args2...,memory_resource*></code> is <code>true</code>, then
<code>yprime</code> is <code>tuple_cat(std::move(y), make_tuple(this->resource()))</code>.</li>
<li>Otherwise the program is ill formed.</li>
</ul>
then this function constructs a <code>std::pair<T1,T2></code> object at <code>p</code> using constructor arguments <code>piecewise_construct, xprime, yprime</code>.
</cxx-effects>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T1, class T2>
void construct(std::pair<T1,T2>* p);</cxx-signature>
<cxx-effects>Equivalent to <code>this->construct(p, piecewise_construct, tuple<>(), tuple<>());</code></cxx-effects>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T1, class T2, class U, class V>
void construct(std::pair<T1,T2>* p, U&& x, V&& y);</cxx-signature>
<cxx-effects>Equivalent to <code>this->construct(p, piecewise_construct, <w-br></w-br>forward_as_tuple(std::forward<U>(x)), <w-br></w-br>forward_as_tuple(std::forward<V>(y)));</code></cxx-effects>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T1, class T2, class U, class V>
void construct(std::pair<T1,T2>* p, const std::pair<U, V>& pr);</cxx-signature>
<cxx-effects>Equivalent to <code>this->construct(p, piecewise_construct, <w-br></w-br>forward_as_tuple(pr.first), <w-br></w-br>forward_as_tuple(pr.second));</code></cxx-effects>
</cxx-function>
<cxx-function>