-
Notifications
You must be signed in to change notification settings - Fork 29
/
utilities.html
1623 lines (1354 loc) · 68 KB
/
utilities.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="utilities">
<h1>General utilities library</h1>
<cxx-section id="propagate_const">
<h1>Constness propagation</h1>
<cxx-section id="propagate_const.syn">
<h1>Header <code><experimental/propagate_const></code> synopsis</h1>
<pre><code>namespace std {
namespace experimental::inline fundamentals_v3 {
<cxx-ref insynopsis to="propagate_const.overview"></cxx-ref>
template <class T> class propagate_const;
<cxx-ref insynopsis to="propagate_const.relational"></cxx-ref>
template <class T>
constexpr bool operator==(const propagate_const<T>& pt, nullptr_t);
template <class T>
constexpr bool operator==(nullptr_t, const propagate_const<T>& pu);
template <class T>
constexpr bool operator!=(const propagate_const<T>& pt, nullptr_t);
template <class T>
constexpr bool operator!=(nullptr_t, const propagate_const<T>& pu);
template <class T, class U>
constexpr bool operator==(const propagate_const<T>& pt,
const propagate_const<U>& pu);
template <class T, class U>
constexpr bool operator!=(const propagate_const<T>& pt,
const propagate_const<U>& pu);
template <class T, class U>
constexpr bool operator<(const propagate_const<T>& pt,
const propagate_const<U>& pu);
template <class T, class U>
constexpr bool operator>(const propagate_const<T>& pt,
const propagate_const<U>& pu);
template <class T, class U>
constexpr bool operator<=(const propagate_const<T>& pt,
const propagate_const<U>& pu);
template <class T, class U>
constexpr bool operator>=(const propagate_const<T>& pt,
const propagate_const<U>& pu);
template <class T, class U>
constexpr bool operator==(const propagate_const<T>& pt, const U& u);
template <class T, class U>
constexpr bool operator!=(const propagate_const<T>& pt, const U& u);
template <class T, class U>
constexpr bool operator<(const propagate_const<T>& pt, const U& u);
template <class T, class U>
constexpr bool operator>(const propagate_const<T>& pt, const U& u);
template <class T, class U>
constexpr bool operator<=(const propagate_const<T>& pt, const U& u);
template <class T, class U>
constexpr bool operator>=(const propagate_const<T>& pt, const U& u);
template <class T, class U>
constexpr bool operator==(const T& t, const propagate_const<U>& pu);
template <class T, class U>
constexpr bool operator!=(const T& t, const propagate_const<U>& pu);
template <class T, class U>
constexpr bool operator<(const T& t, const propagate_const<U>& pu);
template <class T, class U>
constexpr bool operator>(const T& t, const propagate_const<U>& pu);
template <class T, class U>
constexpr bool operator<=(const T& t, const propagate_const<U>& pu);
template <class T, class U>
constexpr bool operator>=(const T& t, const propagate_const<U>& pu);
<cxx-ref insynopsis to="propagate_const.algorithms"></cxx-ref>
template <class T>
constexpr void swap(propagate_const<T>& pt,
propagate_const<T>& pt2) noexcept(<i>see below</i>);
<cxx-ref insynopsis to="propagate_const.underlying"></cxx-ref>
template <class T>
constexpr const T& get_underlying(const propagate_const<T>& pt) noexcept;
template <class T>
constexpr T& get_underlying(propagate_const<T>& pt) noexcept;
} // namespace experimental::inline fundamentals_v3
<cxx-ref insynopsis to="propagate_const.hash"></cxx-ref>
template <class T> struct hash;
template <class T>
struct hash<experimental::fundamentals_v3::propagate_const<T>>;
<cxx-ref insynopsis to="propagate_const.comparison_function_objects"></cxx-ref>
template <class T> struct equal_to;
template <class T>
struct equal_to<experimental::fundamentals_v3::propagate_const<T>>;
template <class T> struct not_equal_to;
template <class T>
struct not_equal_to<experimental::fundamentals_v3::propagate_const<T>>;
template <class T> struct less;
template <class T>
struct less<experimental::fundamentals_v3::propagate_const<T>>;
template <class T> struct greater;
template <class T>
struct greater<experimental::fundamentals_v3::propagate_const<T>>;
template <class T> struct less_equal;
template <class T>
struct less_equal<experimental::fundamentals_v3::propagate_const<T>>;
template <class T> struct greater_equal;
template <class T>
struct greater_equal<experimental::fundamentals_v3::propagate_const<T>>;
} // namespace std</code></pre>
</cxx-section>
<cxx-section id="propagate_const.tmpl">
<h1>Class template <code>propagate_const</code></h1>
<cxx-section id="propagate_const.overview">
<h1>Overview</h1>
<pre><code>namespace std::experimental::inline fundamentals_v3 {
template <class T> class propagate_const {
public:
using element_type = remove_reference_t<decltype(*declval<T&>())>;
<cxx-ref insynopsis to="propagate_const.ctor"></cxx-ref>
constexpr propagate_const() = default;
propagate_const(const propagate_const& p) = delete;
constexpr propagate_const(propagate_const&& p) = default;
template <class U>
explicit(!is_convertible_v<U, T>)
constexpr propagate_const(propagate_const<U>&& pu);
template <class U>
explicit(!is_convertible_v<U, T>)
constexpr propagate_const(U&& u);
<cxx-ref insynopsis to="propagate_const.assignment"></cxx-ref>
propagate_const& operator=(const propagate_const& p) = delete;
constexpr propagate_const& operator=(propagate_const&& p) = default;
template <class U>
constexpr propagate_const& operator=(propagate_const<U>&& pu);
template <class U>
constexpr propagate_const& operator=(U&& u);
<cxx-ref insynopsis to="propagate_const.const_observers"></cxx-ref>
explicit constexpr operator bool() const;
constexpr const element_type* operator->() const;
constexpr operator const element_type*() const; // <i>Not always defined</i>
constexpr const element_type& operator*() const;
constexpr const element_type* get() const;
<cxx-ref insynopsis to="propagate_const.non_const_observers"></cxx-ref>
constexpr element_type* operator->();
constexpr operator element_type*(); // <i>Not always defined</i>
constexpr element_type& operator*();
constexpr element_type* get();
<cxx-ref insynopsis to="propagate_const.modifiers"></cxx-ref>
constexpr void swap(propagate_const& pt) noexcept(is_nothrow_swappable<T>);
private:
T t_; //<i>exposition only</i>
};
} // namespace std::experimental::inline fundamentals_v3</code></pre>
<p>
<code>propagate_const</code> is a wrapper around a pointer-like object type <code>T</code>
which treats the wrapped pointer as a pointer to <code>const</code> when
the wrapper is accessed through a <code>const</code> access path.
</p>
</cxx-section>
<cxx-section id="propagate_const.requirements">
<h1>General requirements on <code>T</code></h1>
<p>
<code>T</code> shall be a cv-unqualified pointer-to-object type or a cv-unqualified class type for which
<code>decltype(*declval<T&>())</code> is an lvalue reference to object type; otherwise
the program is ill-formed.
</p>
<p>
<cxx-note><code>propagate_const<const int*></code> is well-formed but <code>propagate_const<int* const> is not</code>.</cxx-note>
</p>
</cxx-section>
<cxx-section id="propagate_const.class_type_requirements">
<h1>Requirements on class type <code>T</code></h1>
<p>
If <code>T</code> is class
type then it shall satisfy the following requirements. In this subclause
<code>t</code> denotes an lvalue of type <code>T</code>, <code>ct</code>
denotes <code>as_const(t)</code>.
</p>
<p>
<code>T</code> and <code>const T</code> shall be contextually convertible to <code>bool</code>.
</p>
<p>If <code>T</code> is implicitly convertible to <code>element_type*</code>,
<code>(element_type*)t == t.get()</code> shall be <code>true</code>.
</p>
<p>
If <code>const T</code> is implicitly convertible to <code>const element_type*</code>,
<code>(const element_type*)ct == ct.get()</code> shall be <code>true</code>.
</p>
<table is="cxx-table">
<caption>Requirements on class types <code>T</code></caption>
<tr>
<th>Expression</th>
<th>Return type</th>
<th>Pre-conditions</th>
<th>Operational semantics</th>
</tr>
<tr>
<td><code>t.get()</code></td>
<td><code>element_type*</code></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>ct.get()</code></td>
<td><code>const element_type*</code> or <code>element_type*</code></td>
<td><code></code></td>
<td><code>t.get() == ct.get()</code>.</td>
</tr>
<tr>
<td><code>*t</code></td>
<td><code>element_type&</code></td>
<td><code>t.get() != nullptr</code></td>
<td><code>*t</code> refers to the same object as <code>*(t.get())</code></td>
</tr>
<tr>
<td><code>*ct</code></td>
<td><code>const element_type&</code> or <code>element_type&</code></td>
<td><code>ct.get() != nullptr</code></td>
<td><code>*ct</code> refers to the same object as <code>*(ct.get())</code></td>
</tr>
<tr>
<td><code>t.operator->()</code></td>
<td><code>element_type*</code></td>
<td><code>t.get() != nullptr</code></td>
<td><code>t.operator->() == t.get()</code></td></tr>
<tr>
<td><code>ct.operator->()</code></td>
<td><code>const element_type*</code> or <code>element_type*</code></td>
<td><code>ct.get() != nullptr</code></td>
<td><code>ct.operator->() == ct.get()</code></td></tr>
<tr>
<td><code>(bool)t</code></td>
<td><code>bool</code></td>
<td><code></code></td>
<td><code>(bool)t</code> is equivalent to <code>t.get() != nullptr</code></td>
</tr>
<tr>
<td><code>(bool)ct</code></td>
<td><code>bool</code></td>
<td><code></code></td>
<td><code>(bool)ct</code> is equivalent to <code>ct.get() != nullptr</code></td>
</tr>
</table>
</cxx-section>
<cxx-section id="propagate_const.ctor">
<h1>Constructors</h1>
<cxx-function>
<cxx-signature>template <class U>
explicit(!is_convertible_v<U, T>)
constexpr propagate_const(propagate_const<U>&& pu);</cxx-signature>
<cxx-constraints>
<code>is_constructible_v<T, U></code> is true.
</cxx-constraints>
<cxx-effects>
Initializes <code>t_</code> as if
direct-non-list-initializing an object of type <code>T</code> with the
expression <code>std::move(pu.t_)</code>.
</cxx-effects>
</cxx-function>
<cxx-function>
<cxx-signature>template <class U>
explicit(!is_convertible_v<U, T>) constexpr propagate_const(U&& u);</cxx-signature>
<cxx-constraints>
<code>is_constructible_v<T, U></code> is true
and <code>decay_t<U></code> is not a specialization of <code>propagate_const</code>.
</cxx-constraints>
<cxx-effects>
Initializes <code>t_</code> as if
direct-non-list-initializing an object of type <code>T</code> with
the expression <code>std::forward<U>(u)</code>.
</cxx-effects>
</cxx-function>
</cxx-section>
<cxx-section id="propagate_const.assignment">
<h1>Assignment</h1>
<cxx-function>
<cxx-signature>template <class U>
constexpr propagate_const& operator=(propagate_const<U>&& pu);</cxx-signature>
<cxx-constraints>
<code>U</code> is implicitly convertible to <code>T</code>.
</cxx-constraints>
<cxx-effects><code>t_ = std::move(pu.t_)</code>.</cxx-effects>
<cxx-returns><code>*this</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>template <class U>
constexpr propagate_const& operator=(U&& u);</cxx-signature>
<cxx-constraints>
<code>U</code> is implicitly convertible to <code>T</code> and
<code>decay_t<U></code> is not a specialization of <code>propagate_const</code>.
</cxx-constraints>
<cxx-effects><code>t_ = std::forward<U>(u)</code>.</cxx-effects>
<cxx-returns><code>*this</code>.</cxx-returns>
</cxx-function>
</cxx-section>
<cxx-section id="propagate_const.const_observers">
<h1>Const observers</h1>
<cxx-function>
<cxx-signature>explicit constexpr operator bool() const;</cxx-signature>
<cxx-returns><code>(bool)t_</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>constexpr const element_type* operator->() const;</cxx-signature>
<cxx-preconditions><code>get() != nullptr</code>.</cxx-preconditions>
<cxx-returns><code>get()</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>constexpr operator const element_type*() const;</cxx-signature>
<cxx-constraints>
<code>T</code> is an object pointer type or
has an implicit conversion to <code>const element_type*</code>.
</cxx-constraints>
<cxx-returns><code>get()</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>constexpr const element_type& operator*() const;</cxx-signature>
<cxx-preconditions><code>get() != nullptr</code>.</cxx-preconditions>
<cxx-returns><code>*get()</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>constexpr const element_type* get() const;</cxx-signature>
<cxx-returns>
<code>t_</code> if <code>T</code> is an object pointer type,
otherwise <code>t_.get()</code>.
</cxx-returns>
</cxx-function>
</cxx-section>
<cxx-section id="propagate_const.non_const_observers">
<h1>Non-const observers</h1>
<cxx-function>
<cxx-signature>constexpr element_type* operator->();</cxx-signature>
<cxx-preconditions><code>get() != nullptr</code>.</cxx-preconditions>
<cxx-returns><code>get()</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>constexpr operator element_type*();</cxx-signature>
<cxx-constraints>
<code>T</code> is an object pointer type or
has an implicit conversion to <code>element_type*</code>.
</cxx-constraints>
<cxx-returns><code>get()</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>constexpr element_type& operator*();</cxx-signature>
<cxx-preconditions><code>get() != nullptr</code>.</cxx-preconditions>
<cxx-returns><code>*get()</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>constexpr element_type* get();</cxx-signature>
<cxx-returns>
<code>t_</code> if <code>T</code> is an object pointer type,
otherwise <code>t_.get()</code>.
</cxx-returns>
</cxx-function>
</cxx-section>
<cxx-section id="propagate_const.modifiers">
<h1>Modifiers</h1>
<cxx-function>
<cxx-signature>constexpr void swap(propagate_const& pt) noexcept(is_nothrow_swappable<T>);</cxx-signature>
<cxx-preconditions>
Lvalues of type <code>T</code> are swappable
(<cxx-ref in="cxx" to="swappable.requirements"></cxx-ref>).
</cxx-preconditions>
<cxx-effects><code>swap(t_, pt.t_)</code>.</cxx-effects>
</cxx-function>
</cxx-section>
<cxx-section id="propagate_const.relational">
<h1>Relational operators</h1>
<cxx-function>
<cxx-signature>template <class T>
constexpr bool operator==(const propagate_const<T>& pt, nullptr_t);</cxx-signature>
<cxx-returns><code>pt.t_ == nullptr</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T>
constexpr bool operator==(nullptr_t, const propagate_const<T>& pt);</cxx-signature>
<cxx-returns><code>nullptr == pt.t_</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T>
constexpr bool operator!=(const propagate_const<T>& pt, nullptr_t);</cxx-signature>
<cxx-returns><code>pt.t_ != nullptr</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T>
constexpr bool operator!=(nullptr_t, const propagate_const<T>& pt);</cxx-signature>
<cxx-returns><code>nullptr != pt.t_</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T, class U>
constexpr bool operator==(const propagate_const<T>& pt,
const propagate_const<U>& pu);</cxx-signature>
<cxx-returns><code>pt.t_ == pu.t_</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T, class U>
constexpr bool operator!=(const propagate_const<T>& pt,
const propagate_const<U>& pu);</cxx-signature>
<cxx-returns><code>pt.t_ != pu.t_</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T, class U>
constexpr bool operator<(const propagate_const<T>& pt,
const propagate_const<U>& pu);</cxx-signature>
<cxx-returns><code>pt.t_ < pu.t_</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T, class U>
constexpr bool operator>(const propagate_const<T>& pt,
const propagate_const<U>& pu);</cxx-signature>
<cxx-returns><code>pt.t_ > pu.t_</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T, class U>
constexpr bool operator<=(const propagate_const<T>& pt,
const propagate_const<U>& pu);</cxx-signature>
<cxx-returns><code>pt.t_ <= pu.t_</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T, class U>
constexpr bool operator>=(const propagate_const<T>& pt,
const propagate_const<U>& pu);</cxx-signature>
<cxx-returns><code>pt.t_ >= pu.t_</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T, class U>
constexpr bool operator==(const propagate_const<T>& pt, const U& u);</cxx-signature>
<cxx-returns><code>pt.t_ == u</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T, class U>
constexpr bool operator!=(const propagate_const<T>& pt, const U& u);</cxx-signature>
<cxx-returns><code>pt.t_ != u</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T, class U>
constexpr bool operator<(const propagate_const<T>& pt, const U& u);</cxx-signature>
<cxx-returns><code>pt.t_ < u</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T, class U>
constexpr bool operator>(const propagate_const<T>& pt, const U& u);</cxx-signature>
<cxx-returns><code>pt.t_ > u</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T, class U>
constexpr bool operator<=(const propagate_const<T>& pt, const U& u);</cxx-signature>
<cxx-returns><code>pt.t_ <= u</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T, class U>
constexpr bool operator>=(const propagate_const<T>& pt, const U& u);</cxx-signature>
<cxx-returns><code>pt.t_ >= u</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T, class U>
constexpr bool operator==(const T& t, const propagate_const<U>& pu);</cxx-signature>
<cxx-returns><code>t == pu.t_</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T, class U>
constexpr bool operator!=(const T& t, const propagate_const<U>& pu);</cxx-signature>
<cxx-returns><code>t != pu.t_</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T, class U>
constexpr bool operator<(const T& t, const propagate_const<U>& pu);</cxx-signature>
<cxx-returns><code>t < pu.t_</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T, class U>
constexpr bool operator>(const T& t, const propagate_const<U>& pu);</cxx-signature>
<cxx-returns><code>t > pu.t_</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T, class U>
constexpr bool operator<=(const T& t, const propagate_const<U>& pu);</cxx-signature>
<cxx-returns><code>t <= pu.t_</code>.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T, class U>
constexpr bool operator>=(const T& t, const propagate_const<U>& pu);</cxx-signature>
<cxx-returns><code>t >= pu.t_</code>.</cxx-returns>
</cxx-function>
</cxx-section>
<cxx-section id="propagate_const.algorithms">
<h1>Specialized algorithms</h1>
<cxx-function>
<cxx-signature>template <class T>
constexpr void swap(propagate_const<T>& pt1,
propagate_const<T>& pt2) noexcept(<i>see below</i>);</cxx-signature>
<cxx-constraints><code>is_swappable_v<T></code> is <code>true</code>.</cxx-constraints>
<cxx-effects>Equivalent to: <code>pt1.swap(pt2)</code>.</cxx-effects>
<cxx-remarks>The expression inside <code>noexcept</code> is equivalent to:
<pre><code>noexcept(pt1.swap(pt2))</code></pre>
</cxx-remarks>
</cxx-function>
</cxx-section>
<cxx-section id="propagate_const.underlying">
<h1>Underlying pointer access</h1>
<p>
Access to the underlying object pointer type is
through free functions rather than member functions.
These functions are intended to resemble cast operations to encourage caution when using them.
</p>
<cxx-function>
<cxx-signature>template <class T>
constexpr const T& get_underlying(const propagate_const<T>& pt) noexcept;</cxx-signature>
<cxx-returns>
a reference to the underlying object pointer type.
</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T>
constexpr T& get_underlying(propagate_const<T>& pt) noexcept;</cxx-signature>
<cxx-returns>
a reference to the underlying object pointer type.
</cxx-returns>
</cxx-function>
</cxx-section>
<cxx-section id="propagate_const.hash">
<h1>Hash support</h1>
<cxx-function>
<cxx-signature>template <class T>
struct hash<experimental::fundamentals_v3::propagate_const<T>>;</cxx-signature>
<p>
The specialization <code>hash<experimental::fundamentals_v3::propagate_const<T>></code>
is enabled (<cxx-ref in="cxx" to="unord.hash"></cxx-ref>) if and only if <code>hash<T></code> is enabled.
When enabled, for an object <code>p</code> of type <code>propagate_const<T></code>,
<code>hash<experimental::fundamentals_v3::propagate_const<T>>()(p)</code>
evaluates to the same value as <code>hash<T>()(p.t_)</code>.
</p>
</cxx-function>
</cxx-section>
<cxx-section id="propagate_const.comparison_function_objects">
<h1>Comparison function objects</h1>
<cxx-function>
<cxx-signature>template <class T>
struct equal_to<experimental::fundamentals_v3::propagate_const<T>>;</cxx-signature>
<p>
For objects <code>p, q</code> of type <code>propagate_const<T></code>,
<code>equal_to<experimental::fundamentals_v3::propagate_const<T>>()(p,
q)</code>
shall evaluate to the same value as <code>equal_to<T>()(p.t_,
q.t_)</code>.
</p>
<cxx-mandates>
The specialization <code>equal_to<T></code> is well-formed.
</cxx-mandates>
<cxx-preconditions>
The specialization <code>equal_to<T></code> is well-defined.
</cxx-preconditions>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T>
struct not_equal_to<experimental::fundamentals_v3::propagate_const<T>>;</cxx-signature>
<p>
For objects <code>p, q</code> of type <code>propagate_const<T></code>,
<code>not_equal_to<experimental::fundamentals_v3::propagate_const<T>>()(p, q)</code>
shall evaluate to the same value as <code>not_equal_to<T>()(p.t_, q.t_)</code>.
</p>
<cxx-mandates>
The specialization <code>not_equal_to<T></code> is well-formed.
</cxx-mandates>
<cxx-preconditions>
The specialization <code>not_equal_to<T></code> is well-defined.
</cxx-preconditions>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T>
struct less<experimental::fundamentals_v3::propagate_const<T>>;</cxx-signature>
<p>
For objects <code>p, q</code> of type <code>propagate_const<T></code>,
<code>less<experimental::fundamentals_v3::propagate_const<T>>()(p, q)</code>
shall evaluate to the same value as <code>less<T>()(p.t_, q.t_)</code>.
</p>
<cxx-mandates>
The specialization <code>less<T></code> is well-formed.
</cxx-mandates>
<cxx-preconditions>
The specialization <code>less<T></code> is well-defined.
</cxx-preconditions>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T>
struct greater<experimental::fundamentals_v3::propagate_const<T>>;</cxx-signature>
<p>
For objects <code>p, q</code> of type <code>propagate_const<T></code>,
<code>greater<experimental::fundamentals_v3::propagate_const<T>>()(p, q)</code>
shall evaluate to the same value as <code>greater<T>()(p.t_, q.t_)</code>.
</p>
<cxx-mandates>
The specialization <code>greater<T></code> is well-formed.
</cxx-mandates>
<cxx-preconditions>
The specialization <code>greater<T></code> is well-defined.
</cxx-preconditions>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T>
struct less_equal<experimental::fundamentals_v3::propagate_const<T>>;</cxx-signature>
<p>
For objects <code>p, q</code> of type <code>propagate_const<T></code>,
<code>less_equal<experimental::fundamentals_v3::propagate_const<T>>()(p, q)</code>
shall evaluate to the same value as <code>less_equal<T>()(p.t_, q.t_)</code>.
</p>
<cxx-mandates>
The specialization <code>less_equal<T></code> is well-formed.
</cxx-mandates>
<cxx-preconditions>
The specialization <code>less_equal<T></code> is well-defined.
</cxx-preconditions>
</cxx-function>
<cxx-function>
<cxx-signature>template <class T>
struct greater_equal<experimental::fundamentals_v3::propagate_const<T>>;</cxx-signature>
<p>
For objects <code>p, q</code> of type <code>propagate_const<T></code>,
<code>greater_equal<experimental::fundamentals_v3::propagate_const<T>>()(p, q)</code>
shall evaluate to the same value as <code>greater_equal<T>()(p.t_, q.t_)</code>.
</p>
<cxx-mandates>
The specialization <code>greater_equal<T></code> is well-formed.
</cxx-mandates>
<cxx-preconditions>
The specialization <code>greater_equal<T></code> is well-defined.
</cxx-preconditions>
</cxx-function>
</cxx-section>
</cxx-section>
</cxx-section>
<cxx-section id="scopeguard">
<h1>Scope guard support</h1>
<cxx-section id="scope.syn">
<h1>Header <code><experimental/scope></code> synopsis</h1>
<pre><code>namespace std::experimental::inline fundamentals_v3 {
<cxx-ref insynopsis to="scopeguard.exit"></cxx-ref>
template <class EF>
class scope_exit;
template <class EF>
class scope_fail;
template <class EF>
class scope_success;
<cxx-ref insynopsis to="scopeguard.uniqueres"></cxx-ref>
template <class R, class D>
class unique_resource;
<cxx-ref insynopsis to="scopeguard.uniqueres.create"></cxx-ref>
template <class R, class D, class S=decay_t<R>>
unique_resource<decay_t<R>, decay_t<D>>
make_unique_resource_checked(
R&& r, const S& invalid, D&& d) noexcept(<i>see below</i>);
} // namespace std::experimental::inline fundamentals_v3</code></pre>
</cxx-section>
<cxx-section id="scopeguard.exit">
<h1>Class templates <code>scope_exit</code>, <code>scope_fail</code>, and <code>scope_success</code></h1>
<p>The class templates <code>scope_exit</code>, <code>scope_fail</code>,
and <code>scope_success</code> define scope guards that wrap a
function object to be called on their destruction.</p>
<p>In this subclause, the placeholder <code><i>scope-guard</i></code>
denotes each of these class templates. In descriptions of the
class members, <code><i>scope-guard</i></code> refers to the enclosing
class.</p>
<pre><code>namespace std::experimental::inline fundamentals_v3 {
template <class EF> class <i>scope-guard</i> {
public:
template <class EFP>
explicit <i>scope-guard</i>(EFP&& f) noexcept(<i>see below</i>);
<i>scope-guard</i>(<i>scope-guard</i>&& rhs) noexcept(<i>see below</i>);
<i>scope-guard</i>(const <i>scope-guard</i>&) = delete;
<i>scope-guard</i>& operator=(const <i>scope-guard</i>&) = delete;
<i>scope-guard</i>& operator=(<i>scope-guard</i>&&) = delete;
~<i>scope-guard</i> () noexcept(<i>see below</i>);
void release() noexcept;
private:
EF exit_function; // <i>exposition only</i>
bool execute_on_destruction{true}; // <i>exposition only</i>
int uncaught_on_creation{uncaught_exceptions()}; // <i>exposition only</i>
};
template <class EF>
<i>scope-guard</i>(EF) -> <i>scope-guard</i><EF>;
} // namespace std::experimental::inline fundamentals_v3</code></pre>
<p>The class template <code>scope_exit</code> is a general-purpose
scope guard that calls its exit function when a scope is exited. The
class templates <code>scope_fail</code> and <code>scope_success</code>
share the <code>scope_exit</code> interface, only the situation when the
exit function is called differs.</p>
<cxx-example><pre><code>void grow(vector<int>& v) {
scope_success guard([]{ cout << "Good!" << endl; });
v.resize(1024);
}</code></pre></cxx-example>
<p><cxx-note>If the exit function object of a <code>scope_success</code>
or <code>scope_exit</code> object refers to a local variable
of the function where it is defined, e.g., as a lambda capturing
the variable by reference, and that variable is used as a return
operand in that function, it is possible for that variable to already have been
returned when the <code><i>scope-guard</i></code>’s destructor
executes, calling the exit function. This can lead to surprising
behavior.</cxx-note></p>
<p>Template argument <code>EF</code> shall be a function object type
(<cxx-ref in="cxx" to="function.objects"></cxx-ref>), lvalue reference
to function, or lvalue reference to function object type. If <code>EF</code>
is an object type, it shall meet the <cxx-17concept>Cpp17Destructible</cxx-17concept>
requirements (C++20 Table 30). Given an lvalue <code>g</code> of type
<code>remove_reference_t<EF></code>, the expression
<code>g()</code> shall be well-formed.</p>
<p>The constructor parameter <code>f</code> in the following constructors
shall be a reference to a function or a reference to a function
object (<cxx-ref in="cxx" to="function.objects"></cxx-ref>).</p>
<cxx-function>
<cxx-signature>template <class EFP>
explicit <i>scope-guard</i>(EFP&& f) noexcept(
is_nothrow_constructible_v<EF, EFP> ||
is_nothrow_constructible_v<EF, EFP&>);</cxx-signature>
<cxx-constraints>
<code>is_same_v<remove_cvref_t<EFP>,
<i>scope-guard</i>></code> is <code>false</code> and
<code>is_constructible_v<EF, EFP></code> is <code>true</code>.
</cxx-constraints>
<cxx-mandates>
The expression <code>f()</code> is well-formed.
</cxx-mandates>
<cxx-preconditions>
Calling <code>f()</code> has well-defined behavior.
For <code>scope_exit</code> and <code>scope_fail</code>,
calling <code>f()</code> does not throw an exception.
</cxx-preconditions>
<cxx-effects>
If <code>EFP</code> is not an lvalue reference type and
<code>is_nothrow_constructible_v<EF, EFP></code>
is <code>true</code>, initialize <code>exit_function</code>
with <code>std::forward<EFP>(f)</code>;
otherwise initialize <code>exit_function</code> with <code>f</code>.
For <code>scope_exit</code> and <code>scope_fail</code>,
if the initialization of <code>exit_function</code> throws an exception,
calls <code>f()</code>.
<cxx-note>For <code>scope_success</code>, <code>f()</code> will not be
called if the initialization fails.</cxx-note>
</cxx-effects>
<cxx-throws>
Any exception thrown during the initialization of <code>exit_function</code>.
</cxx-throws>
</cxx-function>
<cxx-function>
<cxx-signature><i>scope-guard</i>(<i>scope-guard</i>&& rhs) noexcept(<i>see below</i>)</cxx-signature>
<cxx-constraints>
<code>(is_nothrow_move_constructible_v<EF> || is_copy_constructible_v<EF>)</code>
is <code>true</code>.
</cxx-constraints>
<cxx-preconditions>
If <code>EF</code> is an object type:
<ul>
<li>if <code>is_nothrow_move_constructible_v<EF></code> is <code>true</code>,
<code>EF</code> meets the <cxx-17concept>Cpp17MoveConstructible</cxx-17concept> requirements (C++20 Table 26),</li>
<li>otherwise <code>EF</code> meets the <cxx-17concept>Cpp17CopyConstructible</cxx-17concept> requirements (C++20 Table 27).</li>
</ul>
</cxx-preconditions>
<cxx-effects>
If <code>is_nothrow_move_constructible_v<EF></code> is <code>true</code>,
initializes <code>exit_function</code> with <code>std::forward<EF>(rhs.exit_function)</code>,
otherwise initializes <code>exit_function</code> with <code>rhs.exit_function</code>.
Initializes <code>execute_on_destruction</code> from <code>rhs.execute_on_destruction</code> and
<code>uncaught_on_creation</code> from <code>rhs.uncaught_on_creation</code>.
If construction succeeds, call <code>rhs.release()</code>.
<cxx-note>Copying instead of moving provides the strong exception guarantee.</cxx-note>
</cxx-effects>
<cxx-postconditions>
<code>execute_on_destruction</code> yields the value <code>rhs.execute_on_destruction</code>
yielded before the construction. <code>uncaught_on_creation</code> yields the value
<code>rhs.uncaught_on_creation</code> yielded before the construction.
</cxx-postconditions>
<cxx-throws>
Any exception thrown during the initialization of <code>exit_function</code>.
</cxx-throws>
<cxx-remarks>
The expression inside <code>noexcept</code> is equivalent to:
<pre><code>is_nothrow_move_constructible_v<EF> || is_nothrow_copy_constructible_v<EF></code></pre>
</cxx-remarks>
</cxx-function>
<cxx-function>
<cxx-signature>~scope_exit() noexcept(true);</cxx-signature>
<cxx-effects>
Equivalent to:
<pre><code>if (execute_on_destruction)
exit_function();</code></pre>
</cxx-effects>
</cxx-function>
<cxx-function>
<cxx-signature>~scope_fail() noexcept(true);</cxx-signature>
<cxx-effects>
Equivalent to:
<pre><code>if (execute_on_destruction && uncaught_exceptions() > uncaught_on_creation)
exit_function();</code></pre>
</cxx-effects>
</cxx-function>
<cxx-function>
<cxx-signature>~scope_success() noexcept(noexcept(exit_function()));</cxx-signature>
<cxx-effects>
Equivalent to:
<pre><code>if (execute_on_destruction && uncaught_exceptions() <= uncaught_on_creation)
exit_function();</code></pre>
<cxx-note>
If <code>noexcept(exit_function())</code> is <code>false</code>,
<code>exit_function()</code> can throw an exception,
notwithstanding the restrictions of <cxx-ref in="cxx" to="res.on.exception.handling"></cxx-ref>.
</cxx-note>
</cxx-effects>
<cxx-throws>
Any exception thrown by <code>exit_function()</code>.
</cxx-throws>
</cxx-function>
<cxx-function>
<cxx-signature>void release() noexcept;</cxx-signature>
<cxx-effects>
Equivalent to <code>execute_on_destruction = false</code>.
</cxx-effects>
</cxx-function>
</cxx-section>
<cxx-section id="scopeguard.uniqueres">
<h1>Class template <code>unique_resource</code></h1>
<cxx-section id="scopeguard.uniqueres.overview">
<h1>Overview</h1>
<pre><code>namespace std::experimental::inline fundamentals_v3 {
template <class R, class D> class unique_resource {
public:
<cxx-ref insynopsis to="scopeguard.uniqueres.ctor"></cxx-ref>
unique_resource();
template <class RR, class DD>
unique_resource(RR&& r, DD&& d) noexcept(<i>see below</i>);