-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathp2278r4.html
2012 lines (1994 loc) · 338 KB
/
p2278r4.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
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang xml:lang>
<head>
<meta charset="utf-8" />
<meta name="generator" content="mpark/wg21" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<meta name="dcterms.date" content="2022-06-17" />
<title>cbegin should always return a constant iterator</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
color: #aaaaaa;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
div.sourceCode
{ background-color: #f6f8fa; }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span. { } /* Normal */
code span.al { color: #ff0000; } /* Alert */
code span.an { } /* Annotation */
code span.at { } /* Attribute */
code span.bn { color: #9f6807; } /* BaseN */
code span.bu { color: #9f6807; } /* BuiltIn */
code span.cf { color: #00607c; } /* ControlFlow */
code span.ch { color: #9f6807; } /* Char */
code span.cn { } /* Constant */
code span.co { color: #008000; font-style: italic; } /* Comment */
code span.cv { color: #008000; font-style: italic; } /* CommentVar */
code span.do { color: #008000; } /* Documentation */
code span.dt { color: #00607c; } /* DataType */
code span.dv { color: #9f6807; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #9f6807; } /* Float */
code span.fu { } /* Function */
code span.im { } /* Import */
code span.in { color: #008000; } /* Information */
code span.kw { color: #00607c; } /* Keyword */
code span.op { color: #af1915; } /* Operator */
code span.ot { } /* Other */
code span.pp { color: #6f4e37; } /* Preprocessor */
code span.re { } /* RegionMarker */
code span.sc { color: #9f6807; } /* SpecialChar */
code span.ss { color: #9f6807; } /* SpecialString */
code span.st { color: #9f6807; } /* String */
code span.va { } /* Variable */
code span.vs { color: #9f6807; } /* VerbatimString */
code span.wa { color: #008000; font-weight: bold; } /* Warning */
code.diff {color: #898887}
code.diff span.va {color: #006e28}
code.diff span.st {color: #bf0303}
</style>
<style type="text/css">
body {
margin: 5em;
font-family: serif;
hyphens: auto;
line-height: 1.35;
}
div.wrapper {
max-width: 60em;
margin: auto;
}
ul {
list-style-type: none;
padding-left: 2em;
margin-top: -0.2em;
margin-bottom: -0.2em;
}
a {
text-decoration: none;
color: #4183C4;
}
a.hidden_link {
text-decoration: none;
color: inherit;
}
li {
margin-top: 0.6em;
margin-bottom: 0.6em;
}
h1, h2, h3, h4 {
position: relative;
line-height: 1;
}
a.self-link {
position: absolute;
top: 0;
left: calc(-1 * (3.5rem - 26px));
width: calc(3.5rem - 26px);
height: 2em;
text-align: center;
border: none;
transition: opacity .2s;
opacity: .5;
font-family: sans-serif;
font-weight: normal;
font-size: 83%;
}
a.self-link:hover { opacity: 1; }
a.self-link::before { content: "§"; }
ul > li:before {
content: "\2014";
position: absolute;
margin-left: -1.5em;
}
:target { background-color: #C9FBC9; }
:target .codeblock { background-color: #C9FBC9; }
:target ul { background-color: #C9FBC9; }
.abbr_ref { float: right; }
.folded_abbr_ref { float: right; }
:target .folded_abbr_ref { display: none; }
:target .unfolded_abbr_ref { float: right; display: inherit; }
.unfolded_abbr_ref { display: none; }
.secnum { display: inline-block; min-width: 35pt; }
.header-section-number { display: inline-block; min-width: 35pt; }
.annexnum { display: block; }
div.sourceLinkParent {
float: right;
}
a.sourceLink {
position: absolute;
opacity: 0;
margin-left: 10pt;
}
a.sourceLink:hover {
opacity: 1;
}
a.itemDeclLink {
position: absolute;
font-size: 75%;
text-align: right;
width: 5em;
opacity: 0;
}
a.itemDeclLink:hover { opacity: 1; }
span.marginalizedparent {
position: relative;
left: -5em;
}
li span.marginalizedparent { left: -7em; }
li ul > li span.marginalizedparent { left: -9em; }
li ul > li ul > li span.marginalizedparent { left: -11em; }
li ul > li ul > li ul > li span.marginalizedparent { left: -13em; }
div.footnoteNumberParent {
position: relative;
left: -4.7em;
}
a.marginalized {
position: absolute;
font-size: 75%;
text-align: right;
width: 5em;
}
a.enumerated_item_num {
position: relative;
left: -3.5em;
display: inline-block;
margin-right: -3em;
text-align: right;
width: 3em;
}
div.para { margin-bottom: 0.6em; margin-top: 0.6em; text-align: justify; }
div.section { text-align: justify; }
div.sentence { display: inline; }
span.indexparent {
display: inline;
position: relative;
float: right;
right: -1em;
}
a.index {
position: absolute;
display: none;
}
a.index:before { content: "⟵"; }
a.index:target {
display: inline;
}
.indexitems {
margin-left: 2em;
text-indent: -2em;
}
div.itemdescr {
margin-left: 3em;
}
.bnf {
font-family: serif;
margin-left: 40pt;
margin-top: 0.5em;
margin-bottom: 0.5em;
}
.ncbnf {
font-family: serif;
margin-top: 0.5em;
margin-bottom: 0.5em;
margin-left: 40pt;
}
.ncsimplebnf {
font-family: serif;
font-style: italic;
margin-top: 0.5em;
margin-bottom: 0.5em;
margin-left: 40pt;
background: inherit;
}
span.textnormal {
font-style: normal;
font-family: serif;
white-space: normal;
display: inline-block;
}
span.rlap {
display: inline-block;
width: 0px;
}
span.descr { font-style: normal; font-family: serif; }
span.grammarterm { font-style: italic; }
span.term { font-style: italic; }
span.terminal { font-family: monospace; font-style: normal; }
span.nonterminal { font-style: italic; }
span.tcode { font-family: monospace; font-style: normal; }
span.textbf { font-weight: bold; }
span.textsc { font-variant: small-caps; }
a.nontermdef { font-style: italic; font-family: serif; }
span.emph { font-style: italic; }
span.techterm { font-style: italic; }
span.mathit { font-style: italic; }
span.mathsf { font-family: sans-serif; }
span.mathrm { font-family: serif; font-style: normal; }
span.textrm { font-family: serif; }
span.textsl { font-style: italic; }
span.mathtt { font-family: monospace; font-style: normal; }
span.mbox { font-family: serif; font-style: normal; }
span.ungap { display: inline-block; width: 2pt; }
span.textit { font-style: italic; }
span.texttt { font-family: monospace; }
span.tcode_in_codeblock { font-family: monospace; font-style: normal; }
span.phantom { color: white; }
span.math { font-style: normal; }
span.mathblock {
display: block;
margin-left: auto;
margin-right: auto;
margin-top: 1.2em;
margin-bottom: 1.2em;
text-align: center;
}
span.mathalpha {
font-style: italic;
}
span.synopsis {
font-weight: bold;
margin-top: 0.5em;
display: block;
}
span.definition {
font-weight: bold;
display: block;
}
.codeblock {
margin-left: 1.2em;
line-height: 127%;
}
.outputblock {
margin-left: 1.2em;
line-height: 127%;
}
div.itemdecl {
margin-top: 2ex;
}
code.itemdeclcode {
white-space: pre;
display: block;
}
span.textsuperscript {
vertical-align: super;
font-size: smaller;
line-height: 0;
}
.footnotenum { vertical-align: super; font-size: smaller; line-height: 0; }
.footnote {
font-size: small;
margin-left: 2em;
margin-right: 2em;
margin-top: 0.6em;
margin-bottom: 0.6em;
}
div.minipage {
display: inline-block;
margin-right: 3em;
}
div.numberedTable {
text-align: center;
margin: 2em;
}
div.figure {
text-align: center;
margin: 2em;
}
table {
border: 1px solid black;
border-collapse: collapse;
margin-left: auto;
margin-right: auto;
margin-top: 0.8em;
text-align: left;
hyphens: none;
}
td, th {
padding-left: 1em;
padding-right: 1em;
vertical-align: top;
}
td.empty {
padding: 0px;
padding-left: 1px;
}
td.left {
text-align: left;
}
td.right {
text-align: right;
}
td.center {
text-align: center;
}
td.justify {
text-align: justify;
}
td.border {
border-left: 1px solid black;
}
tr.rowsep, td.cline {
border-top: 1px solid black;
}
tr.even, tr.odd {
border-bottom: 1px solid black;
}
tr.capsep {
border-top: 3px solid black;
border-top-style: double;
}
tr.header {
border-bottom: 3px solid black;
border-bottom-style: double;
}
th {
border-bottom: 1px solid black;
}
span.centry {
font-weight: bold;
}
div.table {
display: block;
margin-left: auto;
margin-right: auto;
text-align: center;
width: 90%;
}
span.indented {
display: block;
margin-left: 2em;
margin-bottom: 1em;
margin-top: 1em;
}
ol.enumeratea { list-style-type: none; background: inherit; }
ol.enumerate { list-style-type: none; background: inherit; }
code.sourceCode > span { display: inline; }
</style>
<style type="text/css">a {
color : #4183C4;
text-decoration: underline;
}
a.marginalized {
text-decoration: none;
}
a.self-link {
text-decoration: none;
}
h1#toctitle {
border-bottom: 1px solid #cccccc;
}
#TOC li {
margin-top: 1px;
margin-bottom: 1px;
}
#TOC ul>li:before { display: none; }
h3.subtitle { margin-top: -15px; }
h1:target { background-color: transparent; }
h2:target { background-color: transparent; }
h3:target { background-color: transparent; }
h4:target { background-color: transparent; }
h5:target { background-color: transparent; }
h6:target { background-color: transparent; }
code span.co { font-family: monospace; }
table tr {
background-color: white;
}
table tr:nth-child(2n) {
background-color: #f6f8fa;
}
#title-block-header > table tr:nth-child(2n) {
background-color: white;
}
td > div.sourceCode {
background-color: inherit;
}
table {
border-collapse: collapse;
}
table td, table th {
border: 1px solid #cccccc;
}
table th {
border-bottom: 1px solid black;
text-align: center;
}
table tr:first-child th {
border-top: 0;
}
table tr:last-child td {
border-bottom: 0;
}
table tr td:first-child,
table tr th:first-child {
border-left: 0;
}
table tr td:last-child,
table tr th:last-child {
border-right: 0;
}
table tbody tr:first-child td {
border-top: 1px solid black;
}
#title-block-header td { border: 0; }
@media all {
body {
margin: 2em;
}
}
@media screen and (min-width: 480px) {
body {
margin: 5em;
}
}
#refs code{padding-left: 0px; text-indent: 0px;}
:root {
--diff-ins: #e6ffed;
--diff-strongins: #acf2bd;
--diff-del: #ffdddd;
--diff-strongdel: #ff8888;
}
span.diffins {
background-color: var(--diff-strongins);
}
span.diffdel {
background-color: var(--diff-strongdel);
}
div.rm { text-decoration: line-through; }
div.rm code.sourceCode { text-decoration: line-through; }
div.addu, span.addu {
color: #006e28;
background-color: var(--diff-ins);
}
div.rm pre, div.add pre { background-color: #f6f8fa; }
div.addu pre { background-color: var(--diff-ins); }
div.add, div.add pre { background-color: var(--diff-ins); }
div.addu blockquote {
border-left: 4px solid #00a000;
padding: 0 15px;
color: #006e28;
text-decoration: none;
}
div.addu blockquote code.sourceCode { text-decoration: none; }
div.addu blockquote pre { text-decoration: none; }
div.addu blockquote pre code { text-decoration: none; }
div.quote {
border-left: 7px solid #ccc;
background: #f9f9f9;
margin: 1.5em 10px;
padding-left: 20px;
}
code.diff span.va { color: #000000; background-color: var(--diff-ins); }
code.diff span.st { color: #000000; background-color: var(--diff-del); }
</style>
<link href="data:image/x-icon;base64,AAABAAIAEBAAAAEAIABoBAAAJgAAACAgAAABACAAqBAAAI4EAAAoAAAAEAAAACAAAAABACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////AIJEAACCRAAAgkQAAIJEAACCRAAAgkQAVoJEAN6CRADegkQAWIJEAACCRAAAgkQAAIJEAACCRAAA////AP///wCCRAAAgkQAAIJEAACCRAAsgkQAvoJEAP+CRAD/gkQA/4JEAP+CRADAgkQALoJEAACCRAAAgkQAAP///wD///8AgkQAAIJEABSCRACSgkQA/IJEAP99PQD/dzMA/3czAP99PQD/gkQA/4JEAPyCRACUgkQAFIJEAAD///8A////AHw+AFiBQwDqgkQA/4BBAP9/PxP/uZd6/9rJtf/bybX/upd7/39AFP+AQQD/gkQA/4FDAOqAQgBc////AP///wDKklv4jlEa/3o7AP+PWC//8+3o///////////////////////z7un/kFox/35AAP+GRwD/mVYA+v///wD///8A0Zpk+NmibP+0d0T/8evj///////+/fv/1sKz/9bCs//9/fr//////+/m2/+NRwL/nloA/5xYAPj///8A////ANKaZPjRmGH/5cKh////////////k149/3UwAP91MQD/lmQ//86rhv+USg3/m1YA/5hSAP+bVgD4////AP///wDSmmT4zpJY/+/bx///////8+TV/8mLT/+TVx//gkIA/5lVAP+VTAD/x6B//7aEVv/JpH7/s39J+P///wD///8A0ppk+M6SWP/u2sf///////Pj1f/Nj1T/2KFs/8mOUv+eWhD/lEsA/8aee/+0glT/x6F7/7J8Rvj///8A////ANKaZPjRmGH/48Cf///////+/v7/2qt//82PVP/OkFX/37KJ/86siv+USg7/mVQA/5hRAP+bVgD4////AP///wDSmmT40ppk/9CVXP/69O////////7+/v/x4M//8d/P//7+/f//////9u7n/6tnJf+XUgD/nFgA+P///wD///8A0ppk+NKaZP/RmWL/1qNy//r07///////////////////////+vXw/9akdP/Wnmn/y5FY/6JfFvj///8A////ANKaZFTSmmTo0ppk/9GYYv/Ql1//5cWm//Hg0P/x4ND/5cWm/9GXYP/RmGH/0ppk/9KaZOjVnmpY////AP///wDSmmQA0ppkEtKaZI7SmmT60ppk/9CWX//OkVb/zpFW/9CWX//SmmT/0ppk/NKaZJDSmmQS0ppkAP///wD///8A0ppkANKaZADSmmQA0ppkKtKaZLrSmmT/0ppk/9KaZP/SmmT/0ppkvNKaZCrSmmQA0ppkANKaZAD///8A////ANKaZADSmmQA0ppkANKaZADSmmQA0ppkUtKaZNzSmmTc0ppkVNKaZADSmmQA0ppkANKaZADSmmQA////AP5/AAD4HwAA4AcAAMADAACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAgAEAAMADAADgBwAA+B8AAP5/AAAoAAAAIAAAAEAAAAABACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////AP///wCCRAAAgkQAAIJEAACCRAAAgkQAAIJEAACCRAAAgkQAAIJEAACCRAAAgkQAAIJEAAyCRACMgkQA6oJEAOqCRACQgkQAEIJEAACCRAAAgkQAAIJEAACCRAAAgkQAAIJEAACCRAAAgkQAAIJEAACCRAAA////AP///wD///8A////AIJEAACCRAAAgkQAAIJEAACCRAAAgkQAAIJEAACCRAAAgkQAAIJEAACCRABigkQA5oJEAP+CRAD/gkQA/4JEAP+CRADqgkQAZoJEAACCRAAAgkQAAIJEAACCRAAAgkQAAIJEAACCRAAAgkQAAIJEAAD///8A////AP///wD///8AgkQAAIJEAACCRAAAgkQAAIJEAACCRAAAgkQAAIJEAACCRAA4gkQAwoJEAP+CRAD/gkQA/4JEAP+CRAD/gkQA/4JEAP+CRAD/gkQAxIJEADyCRAAAgkQAAIJEAACCRAAAgkQAAIJEAACCRAAAgkQAAP///wD///8A////AP///wCCRAAAgkQAAIJEAACCRAAAgkQAAIJEAACCRAAWgkQAmIJEAP+CRAD/gkQA/4JEAP+CRAD/gkQA/4JEAP+CRAD/gkQA/4JEAP+CRAD/gkQA/4JEAJyCRAAYgkQAAIJEAACCRAAAgkQAAIJEAACCRAAA////AP///wD///8A////AIJEAACCRAAAgkQAAIJEAACCRAAAgkQAdIJEAPCCRAD/gkQA/4JEAP+CRAD/gkQA/4JEAP+CRAD/gkQA/4JEAP+CRAD/gkQA/4JEAP+CRAD/gkQA/4JEAPSCRAB4gkQAAIJEAACCRAAAgkQAAIJEAAD///8A////AP///wD///8AgkQAAIJEAACCRAAAgkQASoJEANKCRAD/gkQA/4JEAP+CRAD/g0YA/39AAP9zLgD/bSQA/2shAP9rIQD/bSQA/3MuAP9/PwD/g0YA/4JEAP+CRAD/gkQA/4JEAP+CRADUgkQAToJEAACCRAAAgkQAAP///wD///8A////AP///wB+PwAAgkUAIoJEAKiCRAD/gkQA/4JEAP+CRAD/hEcA/4BBAP9sIwD/dTAA/5RfKv+viF7/vp56/76ee/+wiF7/lWAr/3YxAP9sIwD/f0AA/4RHAP+CRAD/gkQA/4JEAP+CRAD/gkQArIJEACaBQwAA////AP///wD///8A////AIBCAEBzNAD6f0EA/4NFAP+CRAD/gkQA/4VIAP92MwD/bSUA/6N1Tv/ezsL/////////////////////////////////38/D/6V3Uv9uJgD/dTEA/4VJAP+CRAD/gkQA/4JEAP+BQwD/fUAA/4FDAEj///8A////AP///wD///8AzJRd5qBlKf91NgD/dDUA/4JEAP+FSQD/cy4A/3YyAP/PuKP//////////////////////////////////////////////////////9K7qP94NQD/ciwA/4VJAP+CRAD/fkEA/35BAP+LSwD/mlYA6v///wD///8A////AP///wDdpnL/4qx3/8KJUv+PUhf/cTMA/3AsAP90LgD/4dK+/////////////////////////////////////////////////////////////////+TYxf91MAD/dTIA/31CAP+GRwD/llQA/6FcAP+gWwD8////AP///wD///8A////ANGZY/LSm2X/4ap3/92mcP+wdT3/byQA/8mwj////////////////////////////////////////////////////////////////////////////+LYxv9zLgP/jUoA/59bAP+hXAD/nFgA/5xYAPL///8A////AP///wD///8A0ppk8tKaZP/RmWL/1p9q/9ubXv/XqXj////////////////////////////7+fD/vZyG/6BxS/+gcUr/vJuE//r37f//////////////////////3MOr/5dQBf+dVQD/nVkA/5xYAP+cWAD/nFgA8v///wD///8A////AP///wDSmmTy0ppk/9KaZP/SmWP/yohJ//jo2P//////////////////////4NTG/4JDFf9lGAD/bSQA/20kAP9kGAD/fz8S/+Xb0f//////5NG9/6txN/+LOgD/m1QA/51aAP+cWAD/m1cA/5xYAP+cWADy////AP///wD///8A////ANKaZPLSmmT/0ppk/8+TWf/Unmv//v37//////////////////////+TWRr/VwsA/35AAP+ERgD/g0UA/4JGAP9lHgD/kFga/8KXX/+TRwD/jT4A/49CAP+VTQD/n10A/5xYAP+OQQD/lk4A/55cAPL///8A////AP///wD///8A0ppk8tKaZP/SmmT/y4tO/92yiP//////////////////////8NnE/8eCQP+rcTT/ez0A/3IyAP98PgD/gEMA/5FSAP+USwD/jj8A/5lUAP+JNwD/yqV2/694Mf+HNQD/jkAA/82rf/+laBj/jT4A8v///wD///8A////AP///wDSmmTy0ppk/9KaZP/LiUr/4byY///////////////////////gupX/0I5P/+Wuev/Lklz/l1sj/308AP+QSwD/ol0A/59aAP+aVQD/k0oA/8yoh///////+fXv/6pwO//Lp3v///////Pr4f+oay7y////AP///wD///8A////ANKaZPLSmmT/0ppk/8uJSv/hvJj//////////////////////+G7l//Jhkb/0ppk/96nc//fqXX/x4xO/6dkFP+QSQD/llEA/5xXAP+USgD/yaOA///////38uv/qG05/8ijdv//////8efb/6ZpLPL///8A////AP///wD///8A0ppk8tKaZP/SmmT/zIxO/9yxh///////////////////////7dbA/8iEQf/Sm2X/0Zlj/9ScZv/eqHf/2KJv/7yAQf+XTgD/iToA/5lSAP+JNgD/yKFv/611LP+HNQD/jT8A/8qmeP+kZRT/jT4A8v///wD///8A////AP///wDSmmTy0ppk/9KaZP/Pk1n/1J5q//78+//////////////////+/fv/1aFv/8iEQv/Tm2b/0ppl/9GZY//Wn2z/1pZc/9eldf/Bl2b/kUcA/4w9AP+OQAD/lUwA/59eAP+cWQD/jT8A/5ZOAP+eXADy////AP///wD///8A////ANKaZPLSmmT/0ppk/9KZY//KiEn/8d/P///////////////////////47+f/05tm/8iCP//KiEj/yohJ/8eCP//RmGH//vfy///////n1sP/rXQ7/4k4AP+TTAD/nVoA/5xYAP+cVwD/nFgA/5xYAPL///8A////AP///wD///8A0ppk8tKaZP/SmmT/0ptl/8uLTf/aq37////////////////////////////+/fz/6c2y/961jv/etY7/6Myx//78+v//////////////////////3MWv/5xXD/+ORAD/mFQA/51ZAP+cWAD/nFgA8v///wD///8A////AP///wDSmmTy0ppk/9KaZP/SmmT/0ppk/8mFRP/s1b//////////////////////////////////////////////////////////////////////////////+PD/0JFU/7NzMv+WUQD/kUsA/5tXAP+dWQDy////AP///wD///8A////ANKaZP/SmmT/0ppk/9KaZP/Sm2X/z5NZ/8yMT//z5NX/////////////////////////////////////////////////////////////////9Ofa/8yNUP/UmGH/36p5/8yTWv+qaSD/kksA/5ROAPz///8A////AP///wD///8A0ppk5NKaZP/SmmT/0ppk/9KaZP/TnGf/zY9T/82OUv/t1sD//////////////////////////////////////////////////////+7Yw//OkFX/zI5R/9OcZ//SmmP/26V0/9ymdf/BhUf/ol8R6P///wD///8A////AP///wDSmmQ80ppk9tKaZP/SmmT/0ppk/9KaZP/TnGj/zpFW/8qJSv/dson/8uHS//////////////////////////////////Lj0//etIv/y4lL/86QVf/TnGj/0ppk/9KaZP/RmWP/05xn/9ymdfjUnWdC////AP///wD///8A////ANKaZADSmmQc0ppkotKaZP/SmmT/0ppk/9KaZP/Tm2b/0Zli/8qJSf/NjlH/16Z3/+G8mP/myKr/5siq/+G8mP/Xp3f/zY5S/8qISf/RmGH/05tm/9KaZP/SmmT/0ppk/9KaZP/SmmSm0pljINWdaQD///8A////AP///wD///8A0ppkANKaZADSmmQA0ppkQtKaZMrSmmT/0ppk/9KaZP/SmmT/0ptl/9GYYf/Nj1P/y4lL/8qISP/KiEj/y4lK/82PU//RmGH/0ptl/9KaZP/SmmT/0ppk/9KaZP/SmmTO0ppkRtKaZADSmmQA0ppkAP///wD///8A////AP///wDSmmQA0ppkANKaZADSmmQA0ppkANKaZGzSmmTu0ppk/9KaZP/SmmT/0ppk/9KaZP/SmmT/0ppk/9KaZP/SmmT/0ppk/9KaZP/SmmT/0ppk/9KaZP/SmmTw0ppkcNKaZADSmmQA0ppkANKaZADSmmQA////AP///wD///8A////ANKaZADSmmQA0ppkANKaZADSmmQA0ppkANKaZBLSmmSQ0ppk/9KaZP/SmmT/0ppk/9KaZP/SmmT/0ppk/9KaZP/SmmT/0ppk/9KaZP/SmmT/0ppklNKaZBTSmmQA0ppkANKaZADSmmQA0ppkANKaZAD///8A////AP///wD///8A0ppkANKaZADSmmQA0ppkANKaZADSmmQA0ppkANKaZADSmmQy0ppkutKaZP/SmmT/0ppk/9KaZP/SmmT/0ppk/9KaZP/SmmT/0ppkvtKaZDbSmmQA0ppkANKaZADSmmQA0ppkANKaZADSmmQA0ppkAP///wD///8A////AP///wDSmmQA0ppkANKaZADSmmQA0ppkANKaZADSmmQA0ppkANKaZADSmmQA0ppkXNKaZODSmmT/0ppk/9KaZP/SmmT/0ppk5NKaZGDSmmQA0ppkANKaZADSmmQA0ppkANKaZADSmmQA0ppkANKaZADSmmQA////AP///wD///8A////ANKaZADSmmQA0ppkANKaZADSmmQA0ppkANKaZADSmmQA0ppkANKaZADSmmQA0ppkBtKaZIbSmmTo0ppk6tKaZIrSmmQK0ppkANKaZADSmmQA0ppkANKaZADSmmQA0ppkANKaZADSmmQA0ppkANKaZAD///8A////AP/8P///+B///+AH//+AAf//AAD//AAAP/AAAA/gAAAHwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA+AAAAfwAAAP/AAAP/8AAP//gAH//+AH///4H////D//" rel="icon" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="wrapper">
<header id="title-block-header">
<h1 class="title" style="text-align:center"><code class="sourceCode cpp">cbegin</code> should always return a constant iterator</h1>
<table style="border:none;float:right">
<tr>
<td>Document #:</td>
<td>P2278R4</td>
</tr>
<tr>
<td>Date:</td>
<td>2022-06-17</td>
</tr>
<tr>
<td style="vertical-align:top">Project:</td>
<td>Programming Language C++</td>
</tr>
<tr>
<td style="vertical-align:top">Audience:</td>
<td>
LEWG<br>
</td>
</tr>
<tr>
<td style="vertical-align:top">Reply-to:</td>
<td>
Barry Revzin<br><<a href="mailto:[email protected]" class="email">[email protected]</a>><br>
</td>
</tr>
</table>
</header>
<div style="clear:both">
<div id="TOC" role="doc-toc">
<h1 id="toctitle">Contents</h1>
<ul>
<li><a href="#revision-history"><span class="toc-section-number">1</span> Revision History<span></span></a></li>
<li><a href="#how-we-got-to-here"><span class="toc-section-number">2</span> How we got to here<span></span></a>
<ul>
<li><a href="#prologue-terminology"><span class="toc-section-number">2.1</span> Prologue: Terminology<span></span></a></li>
<li><a href="#act-i-introduction-of-member-cbegin"><span class="toc-section-number">2.2</span> Act I: Introduction of Member <code class="sourceCode cpp">cbegin</code><span></span></a></li>
<li><a href="#act-ii-rise-of-non-member-cbegin"><span class="toc-section-number">2.3</span> Act II: Rise of Non-Member <code class="sourceCode cpp">cbegin</code><span></span></a></li>
<li><a href="#act-iii-climax-of-the-views"><span class="toc-section-number">2.4</span> Act III: Climax of the Views<span></span></a></li>
<li><a href="#intermezzo-examining-the-c20-status-quo"><span class="toc-section-number">2.5</span> Intermezzo: Examining the C++20 Status Quo<span></span></a></li>
<li><a href="#a-non-solution-member-cbegin"><span class="toc-section-number">2.6</span> A Non-Solution: Member <code class="sourceCode cpp">cbegin<span class="op">()</span></code><span></span></a></li>
</ul></li>
<li><a href="#act-iv-stdconst_iterator"><span class="toc-section-number">3</span> Act IV: <code class="sourceCode cpp">std<span class="op">::</span>const_iterator</code><span></span></a>
<ul>
<li><a href="#a-reverse-digression"><span class="toc-section-number">3.1</span> A Reverse Digression<span></span></a></li>
<li><a href="#const-is-no-different"><span class="toc-section-number">3.2</span> Const Is No Different<span></span></a></li>
<li><a href="#implementing-stdbasic_const_iteratori"><span class="toc-section-number">3.3</span> Implementing <code class="sourceCode cpp">std<span class="op">::</span>basic_const_iterator<span class="op"><</span>I<span class="op">></span></code><span></span></a></li>
<li><a href="#better-algorithms-for-stdrangescbegin-and-stdrangesend"><span class="toc-section-number">3.4</span> Better Algorithms for <code class="sourceCode cpp">std<span class="op">::</span>ranges<span class="op">::</span>cbegin</code> and <code class="sourceCode cpp">std<span class="op">::</span>ranges<span class="op">::</span>end</code><span></span></a></li>
<li><a href="#a-viewsas_const"><span class="toc-section-number">3.5</span> A <code class="sourceCode cpp">views<span class="op">::</span>as_const</code><span></span></a>
<ul>
<li><a href="#naming"><span class="toc-section-number">3.5.1</span> Naming<span></span></a></li>
</ul></li>
<li><a href="#what-about-stdcbegin-and-stdcend"><span class="toc-section-number">3.6</span> What About <code class="sourceCode cpp">std<span class="op">::</span>cbegin</code> and <code class="sourceCode cpp">std<span class="op">::</span>cend</code>?<span></span></a></li>
<li><a href="#now-reverse-it"><span class="toc-section-number">3.7</span> Now Reverse It<span></span></a></li>
<li><a href="#customizing-make_const_iterator"><span class="toc-section-number">3.8</span> Customizing <code class="sourceCode cpp">make_const_iterator</code><span></span></a></li>
<li><a href="#what-does-this-mean-for-spant"><span class="toc-section-number">3.9</span> What does this mean for <code class="sourceCode cpp">span<span class="op"><</span>T<span class="op">></span></code>?<span></span></a></li>
</ul></li>
<li><a href="#act-v-a-concluding-proposal"><span class="toc-section-number">4</span> Act V: A Concluding Proposal<span></span></a>
<ul>
<li><a href="#wording"><span class="toc-section-number">4.1</span> Wording<span></span></a>
<ul>
<li><a href="#span"><span class="toc-section-number">4.1.1</span> Span<span></span></a></li>
<li><a href="#iterators"><span class="toc-section-number">4.1.2</span> Iterators<span></span></a></li>
<li><a href="#ranges"><span class="toc-section-number">4.1.3</span> Ranges<span></span></a></li>
<li><a href="#as-const-view-range.as.const">24.7.? As const view [range.as.const]<span></span></a></li>
<li><a href="#feature-test-macro"><span class="toc-section-number">4.1.4</span> Feature-test macro<span></span></a></li>
</ul></li>
</ul></li>
<li><a href="#epilogue"><span class="toc-section-number">5</span> Epilogue<span></span></a></li>
<li><a href="#bibliography"><span class="toc-section-number">6</span> References<span></span></a></li>
</ul>
</div>
<h1 data-number="1" style="border-bottom:1px solid #cccccc" id="revision-history"><span class="header-section-number">1</span> Revision History<a href="#revision-history" class="self-link"></a></h1>
<p>Since <span class="citation" data-cites="P2278R3">[<a href="#ref-P2278R3" role="doc-biblioref">P2278R3</a>]</span>, wording updates (including a revamp of all the comparison operators) and having <code class="sourceCode cpp">views<span class="op">::</span>as_const<span class="op">(</span>s<span class="op">)</span></code> for a <code class="sourceCode cpp">span<span class="op"><</span>T<span class="op">></span></code> return a <code class="sourceCode cpp">span<span class="op"><</span>T <span class="kw">const</span><span class="op">></span></code>. This ensures that, for instance, <code class="sourceCode cpp">s <span class="op">|</span> views<span class="op">::</span>take<span class="op">(</span>n<span class="op">)</span> <span class="op">|</span> views<span class="op">::</span>as_const</code> and <code class="sourceCode cpp">s <span class="op">|</span> views<span class="op">::</span>as_const <span class="op">|</span> views<span class="op">::</span>take<span class="op">(</span>n<span class="op">)</span></code> both produce the same type.</p>
<p>Since <span class="citation" data-cites="P2278R2">[<a href="#ref-P2278R2" role="doc-biblioref">P2278R2</a>]</span>, renamed <code class="sourceCode cpp">views<span class="op">::</span>all_const</code> back to <code class="sourceCode cpp">views<span class="op">::</span>as_const</code>, see <a href="#naming">naming</a>. Wording fixes.</p>
<p>Since <span class="citation" data-cites="P2278R1">[<a href="#ref-P2278R1" role="doc-biblioref">P2278R1</a>]</span>, renamed <code class="sourceCode cpp">views<span class="op">::</span>as_const</code> to <code class="sourceCode cpp">views<span class="op">::</span>all_const</code>. Added several additional alias templates and a feature-test macro. Fixed some wording issues.</p>
<p>Since <span class="citation" data-cites="P2278R0">[<a href="#ref-P2278R0" role="doc-biblioref">P2278R0</a>]</span>, added wording (including <code class="sourceCode cpp">ranges<span class="op">::</span>cdata</code>, which was omitted in the first revision, and adding member <code class="sourceCode cpp">cbegin</code> and <code class="sourceCode cpp">cend</code> to <code class="sourceCode cpp">view_interface</code>). Renamed <code class="sourceCode cpp">views<span class="op">::</span>as_const</code> to <code class="sourceCode cpp">views<span class="op">::</span>as_const</code>. Also fixed <code class="sourceCode cpp">views<span class="op">::</span>as_const</code> definition to handle deep-const <code class="sourceCode cpp">view</code>s (they do exist).</p>
<h1 data-number="2" style="border-bottom:1px solid #cccccc" id="how-we-got-to-here"><span class="header-section-number">2</span> How we got to here<a href="#how-we-got-to-here" class="self-link"></a></h1>
<p>A tale in many acts.</p>
<h2 data-number="2.1" id="prologue-terminology"><span class="header-section-number">2.1</span> Prologue: Terminology<a href="#prologue-terminology" class="self-link"></a></h2>
<p><span>25.3.1 <a href="https://wg21.link/iterator.requirements.general">[iterator.requirements.general]</a></span>/5 states:</p>
<blockquote>
<p>Iterators that further meet the requirements of output iterators are called <em>mutable iterators</em>. Nonmutable iterators are referred to as <em>constant iterators</em>.</p>
</blockquote>
<p>This paper uses those terms with those meanings: a mutable iterator is one that is writable to, a constant iterator is one that is not writable to.</p>
<h2 data-number="2.2" id="act-i-introduction-of-member-cbegin"><span class="header-section-number">2.2</span> Act I: Introduction of Member <code class="sourceCode cpp">cbegin</code><a href="#act-i-introduction-of-member-cbegin" class="self-link"></a></h2>
<p>In 2004, C++0x had added <code class="sourceCode cpp"><span class="kw">auto</span></code> but not yet added the range-based for statement. So there was this problem: how do you write a for loop that is immutable? The goal of the paper was quite clear:</p>
<div class="quote">
<p>This paper proposes to improve user access to the <code class="sourceCode cpp"><span class="kw">const</span></code> versions of C++ container <code class="sourceCode cpp">iterator</code>s and <code class="sourceCode cpp">reverse_iterator</code>s.</p>
</div>
<p>and:</p>
<div class="quote">
<p>However, when a container traversal is intended for inspection only, it is a generally preferred practice to use a <code class="sourceCode cpp">const_iterator</code> in order to permit the compiler to diagnose <code class="sourceCode cpp"><span class="kw">const</span></code>-correctness violations</p>
</div>
<p>The solution proposed in <span class="citation" data-cites="N1674">[<a href="#ref-N1674" role="doc-biblioref">N1674</a>]</span> (and later adopted by way of <span class="citation" data-cites="N1913">[<a href="#ref-N1913" role="doc-biblioref">N1913</a>]</span>) was to add members <code class="sourceCode cpp">cbegin<span class="op">()</span></code> and <code class="sourceCode cpp">cend<span class="op">()</span></code> (and <code class="sourceCode cpp">crbegin<span class="op">()</span></code> and <code class="sourceCode cpp">crend<span class="op">()</span></code>) to all the standard library containers, facilitating this code:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb1-1"><a href="#cb1-1"></a><span class="cf">for</span> <span class="op">(</span><span class="kw">auto</span> it <span class="op">=</span> v<span class="op">.</span>cbegin<span class="op">()</span>, end <span class="op">=</span> v<span class="op">.</span>cend<span class="op">()</span>; it <span class="op">!=</span> end; <span class="op">++</span>it<span class="op">)</span> <span class="op">{</span></span>
<span id="cb1-2"><a href="#cb1-2"></a> <span class="co">//use *it ...</span></span>
<span id="cb1-3"><a href="#cb1-3"></a><span class="op">}</span></span></code></pre></div>
<p><code class="sourceCode cpp">c<span class="op">.</span>cbegin<span class="op">()</span></code> was specified in all of these containers to perform <code class="sourceCode cpp">as_const<span class="op">(</span>c<span class="op">).</span>begin<span class="op">()</span></code>. Although <code class="sourceCode cpp">std<span class="op">::</span>as_const</code> itself was not added until much later - it is a C++17 feature, first proposed in <span class="citation" data-cites="N4380">[<a href="#ref-N4380" role="doc-biblioref">N4380</a>]</span>.</p>
<h2 data-number="2.3" id="act-ii-rise-of-non-member-cbegin"><span class="header-section-number">2.3</span> Act II: Rise of Non-Member <code class="sourceCode cpp">cbegin</code><a href="#act-ii-rise-of-non-member-cbegin" class="self-link"></a></h2>
<p>C++11 thus added the free functions <code class="sourceCode cpp">std<span class="op">::</span>begin</code> and <code class="sourceCode cpp">std<span class="op">::</span>end</code>, and member functions <code class="sourceCode cpp">c<span class="op">.</span>cbegin<span class="op">()</span></code> and <code class="sourceCode cpp">c<span class="op">.</span>cend<span class="op">()</span></code>. But it did not yet have free functions to fetch constant iterators: those were added in 2013 by way of <span class="citation" data-cites="LWG2128">[<a href="#ref-LWG2128" role="doc-biblioref">LWG2128</a>]</span>.</p>
<p>While, <code class="sourceCode cpp">std<span class="op">::</span>begin<span class="op">(</span>c<span class="op">)</span></code> always calls <code class="sourceCode cpp">c<span class="op">.</span>begin<span class="op">()</span></code> (except for C arrays), <code class="sourceCode cpp">std<span class="op">::</span>cbegin<span class="op">(</span>c<span class="op">)</span></code> was not specified to call <code class="sourceCode cpp">c<span class="op">.</span>cbegin<span class="op">()</span></code>. Instead it, too, called <code class="sourceCode cpp">std<span class="op">::</span>begin<span class="op">(</span>c<span class="op">)</span></code> (not even <code class="sourceCode cpp">c<span class="op">.</span>begin<span class="op">()</span></code>):</p>
<div class="quote">
<p>Implement <code class="sourceCode cpp">std<span class="op">::</span>cbegin</code>/<code class="sourceCode cpp">cend<span class="op">()</span></code> by calling <code class="sourceCode cpp">std<span class="op">::</span>begin</code>/<code class="sourceCode cpp">end<span class="op">()</span></code>. This has numerous advantages:</p>
<ol type="1">
<li>It automatically works with arrays, which is the whole point of these non-member functions.</li>
<li>It works with C++98/03-era user containers, written before <code class="sourceCode cpp">cbegin</code>/<code class="sourceCode cpp">cend<span class="op">()</span></code> members were invented.</li>
<li>It works with <code class="sourceCode cpp">initializer_list</code>, which is extremely minimal and lacks <code class="sourceCode cpp">cbegin</code>/<code class="sourceCode cpp">cend<span class="op">()</span></code> members.</li>
<li>22.2.1 [container.requirements.general] guarantees that this is equivalent to calling <code class="sourceCode cpp">cbegin</code>/<code class="sourceCode cpp">cend<span class="op">()</span></code> members.</li>
</ol>
</div>
<p>There are two important goals here to highlight.</p>
<p>First, the goal is still to provide constant iterators, not just call <code class="sourceCode cpp">begin<span class="op">()</span> <span class="kw">const</span></code>. The latter is an implementation strategy for the former.</p>
<p>Second, the goal is to avoid boilerplate. An implementation where <code class="sourceCode cpp">std<span class="op">::</span>cbegin<span class="op">(</span>c<span class="op">)</span></code> called <code class="sourceCode cpp">c<span class="op">.</span>cbegin<span class="op">()</span></code> would require <code class="sourceCode cpp">c<span class="op">.</span>cbegin<span class="op">()</span></code> to exist, which, as is clear from the list above, is not the case for a lot of useful types.</p>
<p>As a result, <code class="sourceCode cpp">std<span class="op">::</span>cbegin<span class="op">(</span>c<span class="op">)</span></code> is basically specified to be <code class="sourceCode cpp">std<span class="op">::</span>begin<span class="op">(</span>as_const<span class="op">(</span>c<span class="op">))</span></code> (although, again, predating <code class="sourceCode cpp">std<span class="op">::</span>as_const</code>) which is basically <code class="sourceCode cpp">as_const<span class="op">(</span>c<span class="op">).</span>begin<span class="op">()</span></code>.</p>
<p>The status quo at this point is that <code class="sourceCode cpp">c<span class="op">.</span>cbegin<span class="op">()</span></code>, <code class="sourceCode cpp">as_const<span class="op">(</span>c<span class="op">).</span>begin<span class="op">()</span></code>, and <code class="sourceCode cpp">std<span class="op">::</span>cbegin<span class="op">(</span>c<span class="op">)</span></code> are all equivalent (where they are all valid) and all yield constant iterators.</p>
<h2 data-number="2.4" id="act-iii-climax-of-the-views"><span class="header-section-number">2.4</span> Act III: Climax of the Views<a href="#act-iii-climax-of-the-views" class="self-link"></a></h2>
<p>Before 2018, the standard library had two non-owning range types: <code class="sourceCode cpp">std<span class="op">::</span>initializer_list<span class="op"><</span>T<span class="op">></span></code> (since C++11) and <code class="sourceCode cpp">std<span class="op">::</span>string_view</code> (since C++17). Non-owning ranges are shallow-<code class="sourceCode cpp"><span class="kw">const</span></code>, but both of these types are <em>always</em>-<code class="sourceCode cpp"><span class="kw">const</span></code> so that distinction was insignificant.</p>
<p>That soon changed. 2018 opened with the addition of <code class="sourceCode cpp">std<span class="op">::</span>span</code> <span class="citation" data-cites="P0122R7">[<a href="#ref-P0122R7" role="doc-biblioref">P0122R7</a>]</span> and closed with the adoption of Ranges <span class="citation" data-cites="P0896R4">[<a href="#ref-P0896R4" role="doc-biblioref">P0896R4</a>]</span>, with a few more views added the subsequent year by way of <span class="citation" data-cites="P1035R7">[<a href="#ref-P1035R7" role="doc-biblioref">P1035R7</a>]</span>. Now, for the first time, the C++ standard library had non-owning ranges that were nevertheless mutable. Ranges itself was but a small part of the range-v3 library, so there is a promise of many more views to come.</p>
<p>These types really throw a wrench in the <code class="sourceCode cpp">cbegin</code> design: because now <code class="sourceCode cpp">begin<span class="op">()</span> <span class="kw">const</span></code> does not necessarily yield a constant iterator, whereas this had previously always been the case.</p>
<p>It’s important to note that while it had previously always been the case <em>in the standard library</em>, that is not true for the broad C++ community. In particular, Boost.Range (which begat range-v3 which begat C++20 Ranges) has for a very long time had a type named <code class="sourceCode cpp">boost<span class="op">::</span>iterator_range<span class="op"><</span>It<span class="op">></span></code> (the predecessor to <code class="sourceCode cpp">std<span class="op">::</span>ranges<span class="op">::</span>subrange<span class="op"><</span>It<span class="op">></span></code>). This is a view, although that term hadn’t existed yet, and so it had a <code class="sourceCode cpp">begin<span class="op">()</span> <span class="kw">const</span></code> member function that just returned an <code class="sourceCode cpp">It</code>. Which means that <code class="sourceCode cpp">std<span class="op">::</span>cbegin</code> on an <code class="sourceCode cpp">iterator_range<span class="op"><</span><span class="dt">int</span><span class="op">*></span></code> gives you an <code class="sourceCode cpp"><span class="dt">int</span><span class="op">*</span></code> - a mutable iterator.</p>
<p>Where this discrepancy became most apparently visible was the specification of <code class="sourceCode cpp">std<span class="op">::</span>span</code> during the ballot resolution (by way of <span class="citation" data-cites="LWG3320">[<a href="#ref-LWG3320" role="doc-biblioref">LWG3320</a>]</span>). For the sake of simplicity, I am going to assume that the iterator types of <code class="sourceCode cpp">span<span class="op"><</span>T<span class="op">></span></code> and <code class="sourceCode cpp">span<span class="op"><</span>T <span class="kw">const</span><span class="op">></span></code> are just <code class="sourceCode cpp">T<span class="op">*</span></code> and <code class="sourceCode cpp">T <span class="kw">const</span><span class="op">*</span></code>, respectively.</p>
<ul>
<li><code class="sourceCode cpp">span<span class="op"><</span>T<span class="op">>::</span>begin<span class="op">()</span> <span class="kw">const</span></code>, like all the other views, is shallow <code class="sourceCode cpp"><span class="kw">const</span></code>, and so returns <code class="sourceCode cpp">T<span class="op">*</span></code>.</li>
<li><code class="sourceCode cpp">span<span class="op"><</span>T<span class="op">>::</span>cbegin<span class="op">()</span> <span class="kw">const</span></code>, like the other standard library containers, was provided for convenient access to a constant iterator. This returned <code class="sourceCode cpp">T <span class="kw">const</span><span class="op">*</span></code>. Unlike the other standard library containers, this did not simply defer to <code class="sourceCode cpp">begin<span class="op">()</span> <span class="kw">const</span></code>.</li>
</ul>
<p>So far so good. But because <code class="sourceCode cpp">std<span class="op">::</span>cbegin<span class="op">(</span>s<span class="op">)</span></code> is specified to do <code class="sourceCode cpp">std<span class="op">::</span>begin<span class="op">(</span>as_const<span class="op">(</span>s<span class="op">))</span></code>, we end up having different behavior between <code class="sourceCode cpp">s<span class="op">.</span>cbegin<span class="op">()</span></code> and <code class="sourceCode cpp">std<span class="op">::</span>cbegin<span class="op">(</span>s<span class="op">)</span></code>. This is the first (and, thus far, only) type in the standard library for which this is the case - and while <code class="sourceCode cpp">s<span class="op">.</span>cbegin<span class="op">()</span></code> would have yielded a constant iterator, <code class="sourceCode cpp">std<span class="op">::</span>cbegin<span class="op">(</span>s<span class="op">)</span></code> does not.</p>
<p>As a result of NB comment resolution, to ship a coherent C++20, <code class="sourceCode cpp">span</code>’s <code class="sourceCode cpp">cbegin<span class="op">()</span></code> and <code class="sourceCode cpp">cend<span class="op">()</span></code> members were removed, for consistency.</p>
<h2 data-number="2.5" id="intermezzo-examining-the-c20-status-quo"><span class="header-section-number">2.5</span> Intermezzo: Examining the C++20 Status Quo<a href="#intermezzo-examining-the-c20-status-quo" class="self-link"></a></h2>
<p>This leaves us in a state where:</p>
<ul>
<li><p>for all the standard library containers, <code class="sourceCode cpp">r<span class="op">.</span>cbegin<span class="op">()</span></code> and <code class="sourceCode cpp">std<span class="op">::</span>cbegin<span class="op">(</span>r<span class="op">)</span></code> are equivalent, both meaning <code class="sourceCode cpp">as_const<span class="op">(</span>r<span class="op">).</span>begin<span class="op">()</span></code>, and both yielding a constant iterator. This is likely true for many containers defined outside of the standard library as well.</p></li>
<li><p>for most of the standard library views, <code class="sourceCode cpp">r<span class="op">.</span>cbegin<span class="op">()</span></code> does not exist and <code class="sourceCode cpp">std<span class="op">::</span>cbegin<span class="op">(</span>r<span class="op">)</span></code> is a valid expression that could yield a mutable iterator (e.g. <code class="sourceCode cpp">std<span class="op">::</span>span<span class="op"><</span>T<span class="op">></span></code>). There are three different kinds of exceptions:</p>
<ol type="1">
<li><code class="sourceCode cpp">std<span class="op">::</span>string_view<span class="op">::</span>cbegin<span class="op">()</span></code> exists and is a constant iterator (since it is <code class="sourceCode cpp"><span class="kw">const</span></code>-only). <code class="sourceCode cpp">std<span class="op">::</span>initializer_list<span class="op"><</span>T<span class="op">>::</span>cbegin<span class="op">()</span></code> does <em>not</em> exist, but <code class="sourceCode cpp">std<span class="op">::</span>cbegin<span class="op">(</span>il<span class="op">)</span></code> also yields a constant iterator.</li>
<li><code class="sourceCode cpp">std<span class="op">::</span>ranges<span class="op">::</span>single_view<span class="op"><</span>T<span class="op">></span></code> is an owning view and is actually thus deep <code class="sourceCode cpp"><span class="kw">const</span></code>. While it does not have a <code class="sourceCode cpp">cbegin<span class="op">()</span></code> member function, <code class="sourceCode cpp">std<span class="op">::</span>cbegin<span class="op">(</span>v<span class="op">)</span></code> nevertheless yields a constant iterator (the proposed <code class="sourceCode cpp">views<span class="op">::</span>maybe</code> in <span class="citation" data-cites="P1255R6">[<a href="#ref-P1255R6" role="doc-biblioref">P1255R6</a>]</span> would also fit into this category).</li>
<li><code class="sourceCode cpp">std<span class="op">::</span>ranges<span class="op">::</span>filter_view<span class="op"><</span>V, F<span class="op">></span></code> is not actually <code class="sourceCode cpp"><span class="kw">const</span></code>-iterable at all, so it is neither the case that <code class="sourceCode cpp">filt<span class="op">.</span>cbegin<span class="op">()</span></code> exists as a member function nor that <code class="sourceCode cpp">std<span class="op">::</span>cbegin<span class="op">(</span>filt<span class="op">)</span></code> (nor <code class="sourceCode cpp">std<span class="op">::</span>ranges<span class="op">::</span>cbegin<span class="op">(</span>filt<span class="op">)</span></code>) is well-formed. Many other views fit this category as well (<code class="sourceCode cpp">drop_view</code> being the most obvious, but <code class="sourceCode cpp">drop</code>, <code class="sourceCode cpp">reverse</code>, and <code class="sourceCode cpp">join</code> may not be either, etc.). Other future views may fit into this category as well (e.g. my proposed improvement to <code class="sourceCode cpp">views<span class="op">::</span>split</code> in <span class="citation" data-cites="P2210R0">[<a href="#ref-P2210R0" role="doc-biblioref">P2210R0</a>]</span>).</li>
</ol></li>
</ul>
<p>Put differently, the C++20 status quo is that <code class="sourceCode cpp">std<span class="op">::</span>cbegin</code> on an owning range always provides a constant iterator while <code class="sourceCode cpp">std<span class="op">::</span>cbegin</code> on a non-owning view could provide a mutable iterator or not compile at all.</p>
<p>The original desire of Walter’s paper from more than 15 years ago (which, in 2020 terms, may as well have happened at the last Jupiter/Saturn conjunction) still holds today:</p>
<div class="quote">
<p>However, when a container traversal is intended for inspection only, it is a generally preferred practice to use a <code class="sourceCode cpp">const_iterator</code> in order to permit the compiler to diagnose <code class="sourceCode cpp"><span class="kw">const</span></code>-correctness violations</p>
</div>
<p>How could we add <code class="sourceCode cpp"><span class="kw">const</span></code>-correctness to views?</p>
<h2 data-number="2.6" id="a-non-solution-member-cbegin"><span class="header-section-number">2.6</span> A Non-Solution: Member <code class="sourceCode cpp">cbegin<span class="op">()</span></code><a href="#a-non-solution-member-cbegin" class="self-link"></a></h2>
<p>One approach we could take to provide reliable <code class="sourceCode cpp"><span class="kw">const</span></code>-traversal of unknown ranges is to push the problem onto the ranges:</p>
<ol type="1">
<li>We could say that <code class="sourceCode cpp">std<span class="op">::</span>cbegin<span class="op">(</span>c<span class="op">)</span></code> (and <code class="sourceCode cpp">std<span class="op">::</span>ranges<span class="op">::</span>cbegin<span class="op">(</span>c<span class="op">)</span></code> as well) first tries to call <code class="sourceCode cpp">c<span class="op">.</span>cbegin<span class="op">()</span></code> if that exists and only if it doesn’t to fall-back to its present behavior of <code class="sourceCode cpp">std<span class="op">::</span>begin<span class="op">(</span>as_const<span class="op">(</span>c<span class="op">))</span></code>.</li>
<li>We could then pair such a change with going through the standard library and ensuring that all views have a member <code class="sourceCode cpp">cbegin<span class="op">()</span> <span class="kw">const</span></code> that yields a constant iterator. Even the ones like <code class="sourceCode cpp">std<span class="op">::</span>initializer_list<span class="op"><</span>T<span class="op">></span></code> that don’t currently have such a member?</li>
</ol>
<p>Such a design would ensure that for all standard library ranges, <code class="sourceCode cpp">r<span class="op">.</span>cbegin<span class="op">()</span></code> and <code class="sourceCode cpp">std<span class="op">::</span>cbegin<span class="op">(</span>r<span class="op">)</span></code> are equivalent and yield a constant iterator. Except for <code class="sourceCode cpp">filter_view</code>, for which <code class="sourceCode cpp">std<span class="op">::</span>cbegin<span class="op">(</span>filt<span class="op">)</span></code> would continue to not compile as it takes a <code class="sourceCode cpp">C <span class="kw">const</span><span class="op">&</span></code>.</p>
<p>What does this do for all the views outside of the standard library? It does nothing. <code class="sourceCode cpp">std<span class="op">::</span>cbegin<span class="op">(</span>v<span class="op">)</span></code> on such views would continue to yield a mutable iterator, as it does today with <code class="sourceCode cpp">boost<span class="op">::</span>iterator_range</code>. That, in of itself, makes this change somewhat unsatisfactory.</p>
<p>But what would it actually mean to add a member <code class="sourceCode cpp">cbegin<span class="op">()</span> <span class="kw">const</span></code> to every view type? What would such a member function do? What it <em>should</em> do is the exact same thing for every view — the same exact same thing that all views external to the standard library would have to do in order to opt in to <code class="sourceCode cpp"><span class="kw">const</span></code>-traversal-on-demand.</p>
<p>But if every type needs to do the same thing, that’s an algorithm. The standard library should provide it once rather than having every view re-implement it. Or, more likely, have every view delegate to the algorithm and just have boilerplate member function implementations. A substantial amount of view implementations are already boilerplate, we do not need more.</p>
<h1 data-number="3" style="border-bottom:1px solid #cccccc" id="act-iv-stdconst_iterator"><span class="header-section-number">3</span> Act IV: <code class="sourceCode cpp">std<span class="op">::</span>const_iterator</code><a href="#act-iv-stdconst_iterator" class="self-link"></a></h1>
<p>The problem we actually have is this: given an iterator, how do I create an iterator that is identical in all respects except for top-level mutability? This is, ultimately, the problem that from the very beginning <code class="sourceCode cpp">vector<span class="op"><</span>T<span class="op">>::</span>const_iterator</code> is intending to solve. It is a <code class="sourceCode cpp">vector<span class="op"><</span>T<span class="op">>::</span>iterator</code> in all respects (it’s contiguous, its value type is <code class="sourceCode cpp">T</code>, it would have the same bounds coming from the same container) except that dereferencing such an iterator would give a <code class="sourceCode cpp">T <span class="kw">const</span><span class="op">&</span></code> instead of a <code class="sourceCode cpp">T<span class="op">&</span></code>.</p>
<h2 data-number="3.1" id="a-reverse-digression"><span class="header-section-number">3.1</span> A Reverse Digression<a href="#a-reverse-digression" class="self-link"></a></h2>
<p>We’re already used to the fact that some iterators are generic wrappers over other iterators. <code class="sourceCode cpp">vector<span class="op"><</span>T<span class="op">></span></code> is already specified as:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb2-1"><a href="#cb2-1"></a><span class="kw">namespace</span> std <span class="op">{</span></span>
<span id="cb2-2"><a href="#cb2-2"></a> <span class="kw">template</span><span class="op"><</span><span class="kw">class</span> T, <span class="kw">class</span> Allocator <span class="op">=</span> allocator<span class="op"><</span>T<span class="op">>></span></span>
<span id="cb2-3"><a href="#cb2-3"></a> <span class="kw">class</span> vector <span class="op">{</span></span>
<span id="cb2-4"><a href="#cb2-4"></a> <span class="kw">public</span><span class="op">:</span></span>
<span id="cb2-5"><a href="#cb2-5"></a> <span class="co">// types</span></span>
<span id="cb2-6"><a href="#cb2-6"></a></span>
<span id="cb2-7"><a href="#cb2-7"></a> <span class="kw">using</span> iterator <span class="op">=</span> <em>implementation-defined</em>; <span class="co">// see [container.requirements]</span></span>
<span id="cb2-8"><a href="#cb2-8"></a> <span class="kw">using</span> const_iterator <span class="op">=</span> <em>implementation-defined</em>; <span class="co">// see [container.requirements]</span></span>
<span id="cb2-9"><a href="#cb2-9"></a> <span class="kw">using</span> reverse_iterator <span class="op">=</span> std<span class="op">::</span>reverse_iterator<span class="op"><</span>iterator<span class="op">></span>;</span>
<span id="cb2-10"><a href="#cb2-10"></a> <span class="kw">using</span> const_reverse_iterator <span class="op">=</span> std<span class="op">::</span>reverse_iterator<span class="op"><</span>const_iterator<span class="op">></span>;</span></code></pre></div>
<p>Nobody is especially surprised by the fact that every container isn’t manually implementing its own bespoke reverse iterators. <code class="sourceCode cpp">std<span class="op">::</span>reverse_iterator<span class="op"><</span>It<span class="op">></span></code> does the job. Yet, <code class="sourceCode cpp">std<span class="op">::</span>rbegin<span class="op">(</span>c<span class="op">)</span></code> always calls <code class="sourceCode cpp">c<span class="op">.</span>rbegin<span class="op">()</span></code> (except for arrays). Even though we’ve had this perfectly generic solution for a long time, if you wanted your container to support reverse-iteration, you just had to write these boilerplate <code class="sourceCode cpp">rbegin<span class="op">()</span></code>/<code class="sourceCode cpp">rend<span class="op">()</span></code> member functions that wrapped your iterators.</p>
<p>Ranges improved this situation. <code class="sourceCode cpp">std<span class="op">::</span>ranges<span class="op">::</span>rbegin<span class="op">(</span>E<span class="op">)</span></code> is a much more complicated algorithm that takes many steps (see <span>26.3.6 <a href="https://wg21.link/range.access.rbegin">[range.access.rbegin]</a></span> for complete description), but a key aspect of the design there is that if <code class="sourceCode cpp">std<span class="op">::</span>ranges<span class="op">::</span>begin<span class="op">(</span>E<span class="op">)</span></code> and <code class="sourceCode cpp">std<span class="op">::</span>ranges<span class="op">::</span>end<span class="op">(</span>E<span class="op">)</span></code> give you <code class="sourceCode cpp">bidirectional_iterator</code>s, then <code class="sourceCode cpp">std<span class="op">::</span>ranges<span class="op">::</span>rbegin<span class="op">(</span>E<span class="op">)</span></code> itself does the wrapping and provides you <code class="sourceCode cpp">make_reverse_iterator<span class="op">(</span>ranges<span class="op">::</span>end<span class="op">(</span>E<span class="op">))</span></code>. No more pushing work onto the containers. That means that it works even in this case:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb3-1"><a href="#cb3-1"></a><span class="kw">struct</span> simple_span <span class="op">{</span></span>
<span id="cb3-2"><a href="#cb3-2"></a> <span class="dt">int</span><span class="op">*</span> begin<span class="op">()</span> <span class="kw">const</span>;</span>
<span id="cb3-3"><a href="#cb3-3"></a> <span class="dt">int</span><span class="op">*</span> end<span class="op">()</span> <span class="kw">const</span>;</span>
<span id="cb3-4"><a href="#cb3-4"></a><span class="op">}</span>;</span>
<span id="cb3-5"><a href="#cb3-5"></a></span>
<span id="cb3-6"><a href="#cb3-6"></a><span class="dt">void</span> algo<span class="op">(</span>simple_span ss<span class="op">)</span> <span class="op">{</span></span>
<span id="cb3-7"><a href="#cb3-7"></a> <span class="kw">auto</span> rit <span class="op">=</span> std<span class="op">::</span>ranges<span class="op">::</span>rbegin<span class="op">(</span>ss<span class="op">)</span>; <span class="co">// ok</span></span>
<span id="cb3-8"><a href="#cb3-8"></a> <span class="kw">auto</span> rend <span class="op">=</span> std<span class="op">::</span>ranges<span class="op">::</span>rend<span class="op">(</span>ss<span class="op">)</span>; <span class="co">// ok</span></span>
<span id="cb3-9"><a href="#cb3-9"></a> <span class="co">// ...</span></span>
<span id="cb3-10"><a href="#cb3-10"></a><span class="op">}</span></span></code></pre></div>
<p><code class="sourceCode cpp">std<span class="op">::</span>rbegin</code> would’ve failed in this case, because we don’t have the boilerplate necessary to make it work. But instead of pushing that boilerplate onto <code class="sourceCode cpp">simple_span</code>, we consigned it into <code class="sourceCode cpp">std<span class="op">::</span>ranges<span class="op">::</span>rbegin</code>. A much better solution.</p>
<h2 data-number="3.2" id="const-is-no-different"><span class="header-section-number">3.2</span> Const Is No Different<a href="#const-is-no-different" class="self-link"></a></h2>
<p>A generic <code class="sourceCode cpp">reverse_iterator<span class="op"><</span>It<span class="op">></span></code> is not that complicated. We’re basically inverting operations. But the crux of the iterator remains the same: <code class="sourceCode cpp"><span class="op">*</span>it</code> passes through to its underlying iterator.</p>
<p>A generic <code class="sourceCode cpp">const_iterator<span class="op"><</span>It<span class="op">></span></code> at first seems much less complicated. <em>Every</em> operation is passthrough, except for one. We are <em>only</em> modifying the behavior of the dereference operator. Yet, doing the right thing for dereference is decidedly non-trivial. Let’s go through some cases. We’re going to look at both the value type and reference type of several ranges and say what we want the desired <code class="sourceCode cpp">const_iterator<span class="op"><</span>iterator_t<span class="op"><</span>R<span class="op">>></span></code> to dereference into:</p>
<table>
<colgroup>
<col style="width: 25%"></col>
<col style="width: 25%"></col>
<col style="width: 25%"></col>
<col style="width: 25%"></col>
</colgroup>
<thead>
<tr class="header">
<th></th>
<th><div style="text-align:center">
<strong><code class="sourceCode cpp">range_value_t<span class="op"><</span>R<span class="op">></span></code></strong>
</div></th>
<th><div style="text-align:center">
<strong><code class="sourceCode cpp">range_reference_t<span class="op"><</span>R<span class="op">></span></code></strong>
</div></th>
<th><div style="text-align:center">
<strong>desired result type</strong>
</div></th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><code class="sourceCode cpp">vector<span class="op"><</span><span class="dt">int</span><span class="op">></span></code></td>
<td><code class="sourceCode cpp"><span class="dt">int</span></code></td>
<td><code class="sourceCode cpp"><span class="dt">int</span><span class="op">&</span></code></td>
<td><code class="sourceCode cpp"><span class="dt">int</span> <span class="kw">const</span><span class="op">&</span></code></td>
</tr>
<tr class="even">
<td><code class="sourceCode cpp">vector<span class="op"><</span><span class="dt">int</span><span class="op">></span> <span class="kw">const</span></code></td>
<td><code class="sourceCode cpp"><span class="dt">int</span></code></td>
<td><code class="sourceCode cpp"><span class="dt">int</span> <span class="kw">const</span><span class="op">&</span></code></td>
<td><code class="sourceCode cpp"><span class="dt">int</span> <span class="kw">const</span><span class="op">&</span></code></td>
</tr>
<tr class="odd">
<td><code class="sourceCode cpp">array<span class="op"><</span><span class="dt">int</span> <span class="kw">const</span>, N<span class="op">></span></code></td>
<td><code class="sourceCode cpp"><span class="dt">int</span></code></td>
<td><code class="sourceCode cpp"><span class="dt">int</span> <span class="kw">const</span><span class="op">&</span></code></td>
<td><code class="sourceCode cpp"><span class="dt">int</span> <span class="kw">const</span><span class="op">&</span></code></td>
</tr>
<tr class="even">
<td>a range of prvalue <code class="sourceCode cpp"><span class="dt">int</span></code></td>
<td><code class="sourceCode cpp"><span class="dt">int</span></code></td>
<td><code class="sourceCode cpp"><span class="dt">int</span></code></td>
<td><code class="sourceCode cpp"><span class="dt">int</span></code></td>
</tr>
<tr class="odd">
<td><code class="sourceCode cpp">vector<span class="op"><</span><span class="dt">bool</span><span class="op">></span> <span class="kw">const</span></code></td>
<td><code class="sourceCode cpp"><span class="dt">bool</span></code></td>
<td><code class="sourceCode cpp"><span class="dt">bool</span></code></td>
<td><code class="sourceCode cpp"><span class="dt">bool</span></code></td>
</tr>
<tr class="even">
<td><code class="sourceCode cpp">vector<span class="op"><</span><span class="dt">bool</span><span class="op">></span></code></td>
<td><code class="sourceCode cpp"><span class="dt">bool</span></code></td>
<td><code class="sourceCode cpp">vector<span class="op"><</span><span class="dt">bool</span><span class="op">>::</span>reference</code></td>
<td><code class="sourceCode cpp"><span class="dt">bool</span></code></td>
</tr>
<tr class="odd">
<td>zipping a <code class="sourceCode cpp">vector<span class="op"><</span>T<span class="op">></span></code> and <code class="sourceCode cpp">vector<span class="op"><</span>U<span class="op">></span></code></td>
<td><code class="sourceCode cpp">tuple<span class="op"><</span>T, U<span class="op">></span></code></td>
<td><code class="sourceCode cpp">tuple<span class="op"><</span>T<span class="op">&</span>, U<span class="op">&></span></code></td>
<td><code class="sourceCode cpp">tuple<span class="op"><</span>T <span class="kw">const</span><span class="op">&</span>, U <span class="kw">const</span><span class="op">&></span></code></td>
</tr>
</tbody>
</table>
<p>This table points out a few things:</p>
<ul>
<li>A first thought might be that we need to return a <code class="sourceCode cpp">range_value_t<span class="op"><</span>R<span class="op">></span> <span class="kw">const</span><span class="op">&</span></code>, but while that works in some cases, it would lead to every element dangling in other cases.</li>
<li>Sometimes, <code class="sourceCode cpp">It</code> is already a constant iterator, so we would want to actively avoid wrapping in such a case.</li>
<li>The last couple rows are hard.</li>
</ul>
<p>Thankfully, this is a solved problem. The <code class="sourceCode cpp">views<span class="op">::</span>const_</code> adapter <a href="https://github.com/ericniebler/range-v3/blob/d098b9610ac2f182f667ae9274ac2fac7f1327f5/include/range/v3/view/const.hpp">in range-v3</a> has for many years used a formula that works for all of these cases. In C++20 Ranges terms, I would spell it this way:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb4-1"><a href="#cb4-1"></a><span class="kw">template</span> <span class="op"><</span>std<span class="op">::</span>input_iterator It<span class="op">></span></span>
<span id="cb4-2"><a href="#cb4-2"></a><span class="kw">using</span> const_ref_for <span class="op">=</span> std<span class="op">::</span>common_reference_t<span class="op"><</span></span>
<span id="cb4-3"><a href="#cb4-3"></a> std<span class="op">::</span>iter_value_t<span class="op"><</span>It<span class="op">></span> <span class="kw">const</span><span class="op">&&</span>,</span>
<span id="cb4-4"><a href="#cb4-4"></a> std<span class="op">::</span>iter_reference_t<span class="op"><</span>It<span class="op">>></span>;</span></code></pre></div>
<p>This does not yield the correct result for the last row in my table at the moment, but now that we are making the changes to <code class="sourceCode cpp">std<span class="op">::</span>tuple</code> prescribed in <span class="citation" data-cites="P2321R2">[<a href="#ref-P2321R2" role="doc-biblioref">P2321R2</a>]</span>, it soon will.</p>
<p>Avoiding unnecessary wrapping can be achieved through a factory function that checks to see if such wrapping would change type:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb5-1"><a href="#cb5-1"></a><span class="co">// a type is a constant iterator if its an iterator whose reference type is</span></span>
<span id="cb5-2"><a href="#cb5-2"></a><span class="co">// the same as the type that const_ref_for would pick for it</span></span>
<span id="cb5-3"><a href="#cb5-3"></a><span class="kw">template</span> <span class="op"><</span><span class="kw">typename</span> It<span class="op">></span></span>
<span id="cb5-4"><a href="#cb5-4"></a><span class="kw">concept</span> <em>constant-iterator</em> <span class="op">=</span> std<span class="op">::</span>input_iterator<span class="op"><</span>It<span class="op">></span></span>
<span id="cb5-5"><a href="#cb5-5"></a> <span class="op">&&</span> std<span class="op">::</span>same_as<span class="op"><</span>const_ref_for<span class="op"><</span>It<span class="op">></span>, std<span class="op">::</span>iter_reference_t<span class="op"><</span>It<span class="op">>></span>;</span>
<span id="cb5-6"><a href="#cb5-6"></a></span>
<span id="cb5-7"><a href="#cb5-7"></a><span class="co">// a type is a constant range if it is a range whose iterator is a constant iterator</span></span>
<span id="cb5-8"><a href="#cb5-8"></a><span class="kw">template</span> <span class="op"><</span><span class="kw">typename</span> R<span class="op">></span></span>
<span id="cb5-9"><a href="#cb5-9"></a><span class="kw">concept</span> <em>constant-range</em> <span class="op">=</span> std<span class="op">::</span>ranges<span class="op">::</span>range<span class="op"><</span>R<span class="op">></span> <span class="op">&&</span> <em>constant-iterator</em><span class="op"><</span>std<span class="op">::</span>ranges<span class="op">::</span>iterator_t<span class="op"><</span>R<span class="op">>></span>;</span>
<span id="cb5-10"><a href="#cb5-10"></a></span>
<span id="cb5-11"><a href="#cb5-11"></a><span class="kw">template</span> <span class="op"><</span>std<span class="op">::</span>input_iterator It<span class="op">></span></span>
<span id="cb5-12"><a href="#cb5-12"></a><span class="kw">constexpr</span> <span class="kw">auto</span> make_const_iterator<span class="op">(</span>It it<span class="op">)</span> <span class="op">{</span></span>
<span id="cb5-13"><a href="#cb5-13"></a> <span class="cf">if</span> <span class="kw">constexpr</span> <span class="op">(</span><em>constant-iterator</em><span class="op"><</span>It<span class="op">>)</span> <span class="op">{</span></span>
<span id="cb5-14"><a href="#cb5-14"></a> <span class="co">// already a constant iterator</span></span>
<span id="cb5-15"><a href="#cb5-15"></a> <span class="cf">return</span> it;</span>
<span id="cb5-16"><a href="#cb5-16"></a> <span class="op">}</span> <span class="cf">else</span> <span class="op">{</span></span>
<span id="cb5-17"><a href="#cb5-17"></a> <span class="cf">return</span> basic_const_iterator<span class="op"><</span>It<span class="op">>(</span>it<span class="op">)</span>;</span>
<span id="cb5-18"><a href="#cb5-18"></a> <span class="op">}</span></span>
<span id="cb5-19"><a href="#cb5-19"></a><span class="op">}</span></span>
<span id="cb5-20"><a href="#cb5-20"></a></span>
<span id="cb5-21"><a href="#cb5-21"></a><span class="kw">template</span> <span class="op"><</span>std<span class="op">::</span>input_iterator It<span class="op">></span></span>
<span id="cb5-22"><a href="#cb5-22"></a><span class="kw">using</span> const_iterator <span class="op">=</span> <span class="kw">decltype</span><span class="op">(</span>make_const_iterator<span class="op">(</span>std<span class="op">::</span>declval<span class="op"><</span>It<span class="op">>()))</span>;</span></code></pre></div>
<p>Unfortunately we have a lot of names here:</p>
<ul>
<li><code class="sourceCode cpp">const_iterator<span class="op"><</span>I<span class="op">></span></code> is an alias template that gives you a constant iterator version of <code class="sourceCode cpp">I</code>. If <code class="sourceCode cpp">I</code> is already a constant iterator, then <code class="sourceCode cpp">const_iterator<span class="op"><</span>I<span class="op">></span></code> is <code class="sourceCode cpp">I</code>.</li>
<li><code class="sourceCode cpp">make_const_iterator<span class="op"><</span>I<span class="op">>(</span>i<span class="op">)</span></code> is a factory function template that takes an input iterator and produces a <code class="sourceCode cpp">const_iterator<span class="op"><</span>I<span class="op">></span></code>. Likewise, if <code class="sourceCode cpp">I</code> is already a constant iterator, then this function returns <code class="sourceCode cpp">i</code>.</li>
<li><code class="sourceCode cpp">basic_const_iterator<span class="op"><</span>I<span class="op">></span></code> is an implementation detail of the library to satisfy the requirements of the above to ensure that we get a constant iterator.</li>
</ul>
<p>It’s important to have <code class="sourceCode cpp">const_iterator<span class="op"><</span><span class="dt">int</span> <span class="kw">const</span><span class="op">*></span></code> produce the type <code class="sourceCode cpp"><span class="dt">int</span> <span class="kw">const</span><span class="op">*</span></code>. If we just had a single class template <code class="sourceCode cpp">const_iterator</code> (that itself was the implementation for a constant iterator), then it could lead to subtle misuse:</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb6-1"><a href="#cb6-1"></a><span class="kw">template</span> <span class="op"><</span><span class="kw">typename</span> T<span class="op">></span></span>
<span id="cb6-2"><a href="#cb6-2"></a><span class="kw">struct</span> span <span class="op">{</span></span>
<span id="cb6-3"><a href="#cb6-3"></a> <span class="kw">using</span> iterator <span class="op">=</span> <span class="co">/* ... */</span>;</span>
<span id="cb6-4"><a href="#cb6-4"></a> <span class="kw">using</span> const_iterator <span class="op">=</span> std<span class="op">::</span>const_iterator<span class="op"><</span>iterator<span class="op">></span>;</span>
<span id="cb6-5"><a href="#cb6-5"></a><span class="op">}</span>;</span></code></pre></div>
<p><code class="sourceCode cpp">span<span class="op"><</span>T <span class="kw">const</span><span class="op">>::</span>iterator</code> is already a constant iterator, it doesn’t need to be wrapped further. So <code class="sourceCode cpp">span<span class="op"><</span>T <span class="kw">const</span><span class="op">>::</span>const_iterator</code> should really be the same type. It would be nice if the above were already just correct. Hence, the extra names. Users probably never need to use <code class="sourceCode cpp">std<span class="op">::</span>basic_const_iterator<span class="op"><</span>I<span class="op">></span></code> directly (or, indeed, even <code class="sourceCode cpp">make_const_iterator</code>).</p>
<h2 data-number="3.3" id="implementing-stdbasic_const_iteratori"><span class="header-section-number">3.3</span> Implementing <code class="sourceCode cpp">std<span class="op">::</span>basic_const_iterator<span class="op"><</span>I<span class="op">></span></code><a href="#implementing-stdbasic_const_iteratori" class="self-link"></a></h2>
<p>There’s a lot of boilerplate in implementing a C++20 iterator. And especially for <code class="sourceCode cpp">basic_const_iterator<span class="op"><</span>I<span class="op">></span></code> where just about every operation is simply a pass-through to the underlying iterator. Only one function ends up having a body consisting of more than a single <code class="sourceCode cpp"><span class="cf">return</span></code> statement.</p>
<p>Despite that, there’s one especially important aspect to implementing a <code class="sourceCode cpp">basic_const_iterator<span class="op"><</span>I<span class="op">></span></code> that adds complexity: conversions and comparisons. We have this expectation that a range’s mutable iterator is convertible to its constant iterator. That is, given any type <code class="sourceCode cpp">R</code> such <code class="sourceCode cpp">range<span class="op"><</span>R<span class="op">></span></code> and <code class="sourceCode cpp">range<span class="op"><</span>R <span class="kw">const</span><span class="op">></span></code> both hold, that <code class="sourceCode cpp">iterator_t<span class="op"><</span>R<span class="op">></span></code> is convertible to <code class="sourceCode cpp">iterator_t<span class="op"><</span>R <span class="kw">const</span><span class="op">></span></code>. For example, we expect <code class="sourceCode cpp">vector<span class="op"><</span>T<span class="op">>::</span>iterator</code> to be convertible to <code class="sourceCode cpp">vector<span class="op"><</span>T<span class="op">>::</span>const_iterator</code>, and likewise for any other container or view.</p>
<p>Adding the concept of a <code class="sourceCode cpp">const_iterator</code> further complicates matters because now we have the following cross-convertibility and cross-comparability graph:</p>
<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAwAAAACmCAYAAABtLOjgAAAABmJLR0QA/wD/AP+gvaeTAAAgAElEQVR4nO3deVzU1f4/8New76uAUCwibmBpYpqmuTSaC5OWQllmtggt96Z1+6lluZR59XuttFu5lN+u3G/LxW4buC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7t3SZxw71jjtyBGpB2TCBOO0Y8ekWO6/3zgtK0tqBMXFGacVF0uf35SSEinN1J9HaamUptebfi0A2DRyW6tmfl/PngL5+X/A3b3hvNaG1yOqwe+CdeAcACKyWjVzAPR6RyQnA6tXAydOSBXNykopj4cHeKe4Azl1SmocXbsm/ezsLDXeIiOB+HggNhawteUcACKyLpwDQERUj7OzdKc6Lk4aGvTvfwMffSRV/OsPKSHLZmMjNeA8PYHgYOAvfwEeekiaEFyjpnFHRGSt2AAgIqojKAiYN096HD8O/Oc/SkdEzeHuDixcCDz6qNQAICIiY2wAEBE1IDJSWkWGOg5/f2D+fKWjICKybFwFiIiIiIjIirABQERERERkRdgAICIiIiKyImwAEBERERFZEYNJwDqdDhs2bFAqFiIiWRUVFSkdAimkqKiI5R0RWQ1d3S3uUa8B8OKLL+LChQuyBkREpJTnnnsOdnZcDM3a2NnZ4bnnnmN5R0RW48UXXzT42WAnYCIiIiIi6tw4B4CIiIiIyIrYAVivdBBERERERCSP/w+zxbIidP9IvwAAAABJRU5ErkJggg==" title="iterator/const_iterator conversions and comparisons" alt="iterator/const_iterator conversions and comparisons" /></p>
<p>A black arrow from <code class="sourceCode cpp">T</code> to <code class="sourceCode cpp">U</code> indicates that <code class="sourceCode cpp">T</code> needs to be convertible to <code class="sourceCode cpp">U</code>, while the blue bidirectional dotted arrows between <code class="sourceCode cpp">T</code> and <code class="sourceCode cpp">U</code> indicate that <code class="sourceCode cpp">equality_comparable_with<span class="op"><</span>T, U<span class="op">></span></code> holds (i.e. not only that the types can be compared with <code class="sourceCode cpp"><span class="op">==</span></code> and <code class="sourceCode cpp"><span class="op">!=</span></code> but also that there is a common type between them). That is, every pair of types here needs to model <code class="sourceCode cpp">equality_comparable_with</code>.</p>
<p>Even though <code class="sourceCode cpp">iterator_t<span class="op"><</span>R <span class="kw">const</span><span class="op">></span></code> and <code class="sourceCode cpp">const_iterator<span class="op"><</span>iterator_t<span class="op"><</span>R<span class="op">>></span></code> are not convertible to each other, they still have a common type that both are convertible to (<code class="sourceCode cpp">const_iterator<span class="op"><</span>iterator_t<span class="op"><</span>R <span class="kw">const</span><span class="op">>></span></code>) which also needs to be reflected.</p>
<p>The implementation of <code class="sourceCode cpp">basic_const_iterator<span class="op"><</span>I<span class="op">></span></code> needs to properly support this graph: which means ensuring the right set of constructors, comparison operators, and even specializations of <code class="sourceCode cpp">common_type</code>.</p>
<p>The same sort of idea holds for sentinels. How would we wrap sentinels? Imagine a hypothetical <code class="sourceCode cpp">const_sentinel<span class="op"><</span>I, S<span class="op">></span></code>. It would have to have the following behavior:</p>
<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAwAAAACkCAYAAAAg5EnrAAAABmJLR0QA/wD/AP+gvaeTAAAgAElEQVR4nO3dd3gVVf4/8PdN7z0EWCChSAsKhmqjPwgo+BMQQUERhCA2UFZwsYAEFAVFFykriCyw6uLaUfgKKsWAC5GgQDCSUAKmQEJ6u0nO74+zhNzMbSl35pb363nuA3c+c2c+d+7knDlzZs7ohBACRERERETkEty0ToCIiIiIiNTDBgARERERkQvxqPumTZs28PLy0ioXIiKbKi0txRtvvIGpU6dqnQqpJCcnB127dkVISIjWqRAR2URRURG++OIL3HrrrVZ/xqAB4OXlhfT09GZPjIjIHixbtgyVlZVap0EqqqmpQdeuXZGYmKh1KkRENjFt2jRUVVU16DO8BIiIiIiIyIWwAUBERERE5ELYACAiIiIiciFsABARERERuRA2AIiIiIiIXAgbAERERERELoQNACIiIiIiF8IGgJPp1asX9uzZo3UaREREDq256tP8/HzodDrodDoMHjy46YkRNQM2AJxMcnIyhg8frpiekJCA2bNnq5qLI6zz9OnTtQWzr68v4uLisHv3bhtmSERE9sBSfWGqPm2okJAQCCGwY8eORi+DdRs1NzYAiACUlZUhLy8PU6ZMwfjx45Gfn691SkRERE3Cuo1MYQPASSxevLi2tV+3y/LgwYPQ6XR48cUXsWHDhtp5iouLa+fJzs7Gfffdh7CwMNxwww347LPPDJYdExODBQsWoH379nBzc8Pt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nSdS5YsEWFhYSIkJES88sorinlNrdPctrO0zsZ+f1tsg8Z+f1ttA0vrNKX+qAJCCPHdd9+JkJAQUWhqCBUXY2oUoOpqIfbvF+LBB+U15rwHwD7cc48QHTrIG7UzMozPY+0oQI5SB5hbrrkyzlyu5vKxVOaaW66lMlcIIebPn1+7jqtXr1r8/o5UB1gq/82t05KG7j/NUf4nJSUJDw8PceLECavztNX+KkTj9lm191dLuZqiRX1d/xhfJ8T1PosOHTogPT29cS0JIiI7t2zZMrRs2RIzZswwOY9eL19+fiomRkYVFADBwebn6d27N/bs2YPQ0FB1kiJyUq+88gquXr3aoN4Ychz1j/Fd4h4AIiJreXrKF2nP0sE/ETWfl156SesUSEUucQ+APbl217ax1+HDh7VOj1TAfYDIdfHvn7gPOBZn/b3YA6AyYYORgcixcB8gcl38+yfuA47FWX8v9gAQEREREbkQNgCIiIiIiFwIGwBERERERC6EDQAiIiIiIhfCBgARERERkQthA4CIiIiIyIWwAUBERERE5EIMngNQVVWFn3/+WatciIhs6uLFi2jZsqXWaVAzS0pKQmBgoNZpEBHZraqqKoP3Bg2A4cOHY/Xq1aomRESkpo4dO2qdAjWjkSNHYtOmTVqnQURk14YPH27wXiec9RFnRERERESkwHsAiIiIiIhciAeAHVonQURERERE6vj/xXoR/xL+DaMAAAAASUVORK5CYII=" alt /></p>
<p>Because <code class="sourceCode cpp">iterator_t<span class="op"><</span>R <span class="kw">const</span><span class="op">></span></code> would be comparable to <code class="sourceCode cpp">sentinel_t<span class="op"><</span>R<span class="op">></span></code>, it needs to follow that <code class="sourceCode cpp">const_iterator<span class="op"><</span>iterator_t<span class="op"><</span>R<span class="op">>></span></code> needs to be comparable to <code class="sourceCode cpp">sentinel_t<span class="op"><</span>R<span class="op">></span></code> as well. That is, <code class="sourceCode cpp">sentinel_for<span class="op"><</span>const_iterator<span class="op"><</span>I<span class="op">></span>, S<span class="op">></span></code> needs to hold whenever <code class="sourceCode cpp">sentinel_for<span class="op"><</span>I, S<span class="op">></span></code> holds. This begs the question of if we need a <code class="sourceCode cpp">const_sentinel<span class="op"><</span>I, S<span class="op">></span></code> type at all, given that we need to support comparisons to the unwrapped sentinel anyway. It’s a complex interplay of types to get right, and it doesn’t seem like a <code class="sourceCode cpp">const_sentinel</code> type adds value for us at all. Hopefully, we don’t find a problem that necessitates wrapping in the future (c.f. <span class="citation" data-cites="LWG3386">[<a href="#ref-LWG3386" role="doc-biblioref">LWG3386</a>]</span>).</p>
<p>The tricky part of the implementation is to avoid constraint recursion in ensuring that wrapped random access iterators are totally ordered and ensuring that wrapped sized sentinels are still sized sentinels. A first attempt at attempting to define an <code class="sourceCode cpp"><span class="kw">operator</span><span class="op"><=></span></code> for <code class="sourceCode cpp">basic_const_iterator<span class="op"><</span>I<span class="op">></span></code> might start with:</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb7-1"><a href="#cb7-1"></a><span class="kw">template</span> <span class="op"><</span>std<span class="op">::</span>input_iterator It<span class="op">></span></span>
<span id="cb7-2"><a href="#cb7-2"></a><span class="kw">struct</span> basic_const_iterator <span class="op">{</span></span>
<span id="cb7-3"><a href="#cb7-3"></a> <span class="kw">template</span> <span class="op"><</span>std<span class="op">::</span>totally_ordered_with<span class="op"><</span>It<span class="op">></span> Rhs<span class="op">></span></span>
<span id="cb7-4"><a href="#cb7-4"></a> <span class="kw">requires</span> std<span class="op">::</span>random_access_iterator<span class="op"><</span>It<span class="op">></span></span>
<span id="cb7-5"><a href="#cb7-5"></a> <span class="kw">auto</span> <span class="kw">operator</span><span class="op"><=>(</span>Rhs <span class="kw">const</span><span class="op">&</span> rhs<span class="op">)</span> <span class="kw">const</span>;</span>
<span id="cb7-6"><a href="#cb7-6"></a><span class="op">}</span>;</span></code></pre></div>
<p>But when checking to see if <code class="sourceCode cpp">totally_ordered<span class="op"><</span>basic_const_iterator<span class="op"><</span><span class="dt">int</span><span class="op">*>></span></code>, we would check to see if we can instantiate <code class="sourceCode cpp"><span class="kw">operator</span><span class="op"><=></span></code>, which requires checking if <code class="sourceCode cpp">totally_ordered_with<span class="op"><</span>basic_const_iterator<span class="op"><</span><span class="dt">int</span><span class="op">*></span>, basic_const_iterator<span class="op"><</span><span class="dt">int</span><span class="op">*>></span></code> (since <code class="sourceCode cpp">Rhs</code> is our same type), which itself requires checking <code class="sourceCode cpp">totally_ordered<span class="op"><</span>basic_const_iterator<span class="op"><</span><span class="dt">int</span><span class="op">*>></span></code>. And now we’ve completed the cycle.</p>
<p>The way I chose to handle this problem is to split the implementation into two functions: a same-type, non-template comparison and a template that is constrained on different types:</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb8-1"><a href="#cb8-1"></a><span class="kw">template</span> <span class="op"><</span>std<span class="op">::</span>input_iterator It<span class="op">></span></span>
<span id="cb8-2"><a href="#cb8-2"></a><span class="kw">struct</span> basic_const_iterator <span class="op">{</span></span>
<span id="cb8-3"><a href="#cb8-3"></a> <span class="kw">auto</span> <span class="kw">operator</span><span class="op"><=>(</span>basic_const_iterator <span class="kw">const</span><span class="op">&</span> rhs<span class="op">)</span> <span class="kw">const</span></span>
<span id="cb8-4"><a href="#cb8-4"></a> <span class="kw">requires</span> std<span class="op">::</span>random_access_iterator<span class="op"><</span>It<span class="op">></span>;</span>
<span id="cb8-5"><a href="#cb8-5"></a></span>
<span id="cb8-6"><a href="#cb8-6"></a> <span class="kw">template</span> <span class="op"><</span><em>different-from</em><span class="op"><</span>basic_const_iterator<span class="op">></span> Rhs<span class="op">></span></span>
<span id="cb8-7"><a href="#cb8-7"></a> <span class="kw">requires</span> std<span class="op">::</span>random_access_iterator<span class="op"><</span>It<span class="op">></span></span>
<span id="cb8-8"><a href="#cb8-8"></a> <span class="kw">and</span> std<span class="op">::</span>totally_ordered_with<span class="op"><</span>It, Rhs<span class="op">></span></span>
<span id="cb8-9"><a href="#cb8-9"></a> <span class="kw">auto</span> <span class="kw">operator</span><span class="op"><=>(</span>Rhs <span class="kw">const</span><span class="op">&</span> rhs<span class="op">)</span> <span class="kw">const</span>;</span>
<span id="cb8-10"><a href="#cb8-10"></a><span class="op">}</span>;</span></code></pre></div>
<p>Other things to note about this implementation:</p>
<ol type="1">
<li>Providing <code class="sourceCode cpp">iterator_concept <span class="op">=</span> contiguous_iterator_tag;</code> ensures that wrapping a contiguous mutable iterator produces a contiguous constant iterator.</li>
<li>Only providing <code class="sourceCode cpp">iterator_category</code> for <code class="sourceCode cpp">forward_iterator</code>s ensures that we correctly handle C++20 input iterators (more on this later, and see also <span class="citation" data-cites="P2259R0">[<a href="#ref-P2259R0" role="doc-biblioref">P2259R0</a>]</span>).</li>
<li>The spelling of the <code class="sourceCode cpp">reference</code> type for this iterator, described earlier.</li>
</ol>
<div class="sourceCode" id="cb9"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb9-1"><a href="#cb9-1"></a><span class="kw">template</span> <span class="op"><</span><span class="kw">typename</span> It<span class="op">></span> <span class="kw">struct</span> iterator_concept_for <span class="op">{</span> <span class="op">}</span>;</span>
<span id="cb9-2"><a href="#cb9-2"></a><span class="kw">template</span> <span class="op"><</span><span class="kw">typename</span> It<span class="op">></span> <span class="kw">requires</span> std<span class="op">::</span>contiguous_iterator<span class="op"><</span>It<span class="op">></span></span>
<span id="cb9-3"><a href="#cb9-3"></a><span class="kw">struct</span> iterator_concept_for<span class="op"><</span>It<span class="op">></span> <span class="op">{</span></span>
<span id="cb9-4"><a href="#cb9-4"></a> <span class="kw">using</span> iterator_concept <span class="op">=</span> std<span class="op">::</span>contiguous_iterator_tag;</span>
<span id="cb9-5"><a href="#cb9-5"></a><span class="op">}</span>;</span>
<span id="cb9-6"><a href="#cb9-6"></a></span>
<span id="cb9-7"><a href="#cb9-7"></a><span class="kw">template</span> <span class="op"><</span><span class="kw">typename</span> It<span class="op">></span> <span class="kw">struct</span> iterator_category_for <span class="op">{</span> <span class="op">}</span>;</span>
<span id="cb9-8"><a href="#cb9-8"></a><span class="kw">template</span> <span class="op"><</span>std<span class="op">::</span>forward_iterator It<span class="op">></span></span>
<span id="cb9-9"><a href="#cb9-9"></a><span class="kw">struct</span> iterator_category_for<span class="op"><</span>It<span class="op">></span> <span class="op">{</span></span>
<span id="cb9-10"><a href="#cb9-10"></a> <span class="kw">using</span> iterator_category <span class="op">=</span> <span class="kw">typename</span> std<span class="op">::</span>iterator_traits<span class="op"><</span>It<span class="op">>::</span>iterator_category;</span>
<span id="cb9-11"><a href="#cb9-11"></a><span class="op">}</span>;</span>
<span id="cb9-12"><a href="#cb9-12"></a></span>
<span id="cb9-13"><a href="#cb9-13"></a><span class="kw">template</span> <span class="op"><</span>std<span class="op">::</span>input_iterator It<span class="op">></span></span>
<span id="cb9-14"><a href="#cb9-14"></a><span class="kw">class</span> basic_const_iterator <span class="op">:</span> <span class="kw">public</span> iterator_concept_for<span class="op"><</span>It<span class="op">></span></span>
<span id="cb9-15"><a href="#cb9-15"></a> , <span class="kw">public</span> iterator_category_for<span class="op"><</span>It<span class="op">></span></span>
<span id="cb9-16"><a href="#cb9-16"></a><span class="op">{</span></span>
<span id="cb9-17"><a href="#cb9-17"></a> It it;</span>
<span id="cb9-18"><a href="#cb9-18"></a></span>
<span id="cb9-19"><a href="#cb9-19"></a><span class="kw">public</span><span class="op">:</span></span>
<span id="cb9-20"><a href="#cb9-20"></a> <span class="kw">using</span> value_type <span class="op">=</span> std<span class="op">::</span>iter_value_t<span class="op"><</span>It<span class="op">></span>;</span>
<span id="cb9-21"><a href="#cb9-21"></a> <span class="kw">using</span> difference_type <span class="op">=</span> std<span class="op">::</span>iter_difference_t<span class="op"><</span>It<span class="op">></span>;</span>
<span id="cb9-22"><a href="#cb9-22"></a> <span class="kw">using</span> reference <span class="op">=</span> const_ref_for<span class="op"><</span>It<span class="op">></span>;</span>
<span id="cb9-23"><a href="#cb9-23"></a></span>
<span id="cb9-24"><a href="#cb9-24"></a> basic_const_iterator<span class="op">()</span> <span class="op">=</span> <span class="cf">default</span>;</span>
<span id="cb9-25"><a href="#cb9-25"></a> basic_const_iterator<span class="op">(</span>It it<span class="op">)</span> <span class="op">:</span> it<span class="op">(</span>std<span class="op">::</span>move<span class="op">(</span>it<span class="op">))</span> <span class="op">{</span> <span class="op">}</span></span>
<span id="cb9-26"><a href="#cb9-26"></a> <span class="kw">template</span> <span class="op"><</span>std<span class="op">::</span>convertible_to<span class="op"><</span>It<span class="op">></span> U<span class="op">></span></span>
<span id="cb9-27"><a href="#cb9-27"></a> basic_const_iterator<span class="op">(</span>basic_const_iterator<span class="op"><</span>U<span class="op">></span> c<span class="op">)</span> <span class="op">:</span> it<span class="op">(</span>std<span class="op">::</span>move<span class="op">(</span>c<span class="op">.</span>base<span class="op">()))</span> <span class="op">{</span> <span class="op">}</span></span>
<span id="cb9-28"><a href="#cb9-28"></a> basic_const_iterator<span class="op">(</span>std<span class="op">::</span>convertible_to<span class="op"><</span>It<span class="op">></span> <span class="kw">auto</span><span class="op">&&</span> c<span class="op">)</span> <span class="op">:</span> it<span class="op">(</span>FWD<span class="op">(</span>c<span class="op">))</span> <span class="op">{</span> <span class="op">}</span></span>
<span id="cb9-29"><a href="#cb9-29"></a></span>
<span id="cb9-30"><a href="#cb9-30"></a> <span class="kw">auto</span> <span class="kw">operator</span><span class="op">++()</span> <span class="op">-></span> basic_const_iterator<span class="op">&</span> <span class="op">{</span> <span class="op">++</span>it; <span class="cf">return</span> <span class="op">*</span><span class="kw">this</span>; <span class="op">}</span></span>
<span id="cb9-31"><a href="#cb9-31"></a> <span class="kw">auto</span> <span class="kw">operator</span><span class="op">++(</span><span class="dt">int</span><span class="op">)</span> <span class="op">-></span> basic_const_iterator <span class="kw">requires</span> std<span class="op">::</span>forward_iterator<span class="op"><</span>It<span class="op">></span> <span class="op">{</span> <span class="kw">auto</span> cpy <span class="op">=</span> <span class="op">*</span><span class="kw">this</span>; <span class="op">++*</span><span class="kw">this</span>; <span class="cf">return</span> cpy; <span class="op">}</span></span>
<span id="cb9-32"><a href="#cb9-32"></a> <span class="dt">void</span> <span class="kw">operator</span><span class="op">++(</span><span class="dt">int</span><span class="op">)</span> <span class="op">{</span> <span class="op">++*</span><span class="kw">this</span>; <span class="op">}</span></span>
<span id="cb9-33"><a href="#cb9-33"></a></span>
<span id="cb9-34"><a href="#cb9-34"></a> <span class="kw">auto</span> <span class="kw">operator</span><span class="op">--()</span> <span class="op">-></span> basic_const_iterator<span class="op">&</span> <span class="kw">requires</span> std<span class="op">::</span>bidirectional_iterator<span class="op"><</span>It<span class="op">></span> <span class="op">{</span> <span class="op">--</span>it; <span class="cf">return</span> <span class="op">*</span><span class="kw">this</span>; <span class="op">}</span></span>
<span id="cb9-35"><a href="#cb9-35"></a> <span class="kw">auto</span> <span class="kw">operator</span><span class="op">--(</span><span class="dt">int</span><span class="op">)</span> <span class="op">-></span> basic_const_iterator <span class="kw">requires</span> std<span class="op">::</span>bidirectional_iterator<span class="op"><</span>It<span class="op">></span> <span class="op">{</span> <span class="kw">auto</span> cpy <span class="op">=</span> <span class="op">*</span><span class="kw">this</span>; <span class="op">--*</span><span class="kw">this</span>; <span class="cf">return</span> cpy; <span class="op">}</span></span>
<span id="cb9-36"><a href="#cb9-36"></a></span>
<span id="cb9-37"><a href="#cb9-37"></a> <span class="kw">auto</span> <span class="kw">operator</span><span class="op">+(</span>difference_type n<span class="op">)</span> <span class="kw">const</span> <span class="op">-></span> basic_const_iterator <span class="kw">requires</span> std<span class="op">::</span>random_access_iterator<span class="op"><</span>It<span class="op">></span> <span class="op">{</span> <span class="cf">return</span> basic_const_iterator<span class="op">(</span>it <span class="op">+</span> n<span class="op">)</span>; <span class="op">}</span></span>
<span id="cb9-38"><a href="#cb9-38"></a> <span class="kw">auto</span> <span class="kw">operator</span><span class="op">-(</span>difference_type n<span class="op">)</span> <span class="kw">const</span> <span class="op">-></span> basic_const_iterator <span class="kw">requires</span> std<span class="op">::</span>random_access_iterator<span class="op"><</span>It<span class="op">></span> <span class="op">{</span> <span class="cf">return</span> basic_const_iterator<span class="op">(</span>it <span class="op">-</span> n<span class="op">)</span>; <span class="op">}</span></span>
<span id="cb9-39"><a href="#cb9-39"></a> <span class="kw">friend</span> <span class="kw">auto</span> <span class="kw">operator</span><span class="op">+(</span>difference_type n, basic_const_iterator <span class="kw">const</span><span class="op">&</span> rhs<span class="op">)</span> <span class="op">-></span> basic_const_iterator <span class="op">{</span> <span class="cf">return</span> rhs <span class="op">+</span> n; <span class="op">}</span></span>
<span id="cb9-40"><a href="#cb9-40"></a> <span class="kw">auto</span> <span class="kw">operator</span><span class="op">+=(</span>difference_type n<span class="op">)</span> <span class="op">-></span> basic_const_iterator<span class="op">&</span> <span class="kw">requires</span> std<span class="op">::</span>random_access_iterator<span class="op"><</span>It<span class="op">></span> <span class="op">{</span> it <span class="op">+=</span> n; <span class="cf">return</span> <span class="op">*</span><span class="kw">this</span>; <span class="op">}</span></span>
<span id="cb9-41"><a href="#cb9-41"></a> <span class="kw">auto</span> <span class="kw">operator</span><span class="op">-=(</span>difference_type n<span class="op">)</span> <span class="op">-></span> basic_const_iterator<span class="op">&</span> <span class="kw">requires</span> std<span class="op">::</span>random_access_iterator<span class="op"><</span>It<span class="op">></span> <span class="op">{</span> it <span class="op">-=</span> n; <span class="cf">return</span> <span class="op">*</span><span class="kw">this</span>; <span class="op">}</span></span>
<span id="cb9-42"><a href="#cb9-42"></a> <span class="kw">auto</span> <span class="kw">operator</span><span class="op">-(</span>basic_const_iterator <span class="kw">const</span><span class="op">&</span> rhs<span class="op">)</span> <span class="kw">const</span> <span class="op">-></span> difference_type <span class="kw">requires</span> std<span class="op">::</span>random_access_iterator<span class="op"><</span>It<span class="op">></span> <span class="op">{</span> <span class="cf">return</span> it <span class="op">-</span> rhs<span class="op">.</span>it; <span class="op">}</span></span>
<span id="cb9-43"><a href="#cb9-43"></a> <span class="kw">auto</span> <span class="kw">operator</span><span class="op">[](</span>difference_type n<span class="op">)</span> <span class="kw">const</span> <span class="op">-></span> reference <span class="kw">requires</span> std<span class="op">::</span>random_access_iterator<span class="op"><</span>It<span class="op">></span> <span class="op">{</span> <span class="cf">return</span> it<span class="op">[</span>n<span class="op">]</span>; <span class="op">}</span></span>
<span id="cb9-44"><a href="#cb9-44"></a></span>
<span id="cb9-45"><a href="#cb9-45"></a> <span class="kw">auto</span> <span class="kw">operator</span><span class="op">*()</span> <span class="kw">const</span> <span class="op">-></span> reference <span class="op">{</span> <span class="cf">return</span> <span class="op">*</span>it; <span class="op">}</span></span>
<span id="cb9-46"><a href="#cb9-46"></a> <span class="kw">auto</span> <span class="kw">operator</span><span class="op">->()</span> <span class="kw">const</span> <span class="op">-></span> value_type <span class="kw">const</span><span class="op">*</span> <span class="kw">requires</span> std<span class="op">::</span>contiguous_iterator<span class="op"><</span>It<span class="op">></span> <span class="op">{</span> <span class="cf">return</span> std<span class="op">::</span>to_address<span class="op">(</span>it<span class="op">)</span>; <span class="op">}</span></span>
<span id="cb9-47"><a href="#cb9-47"></a></span>
<span id="cb9-48"><a href="#cb9-48"></a> <span class="kw">template</span> <span class="op"><</span>sentinel_for<span class="op"><</span>It<span class="op">></span> S<span class="op">></span></span>
<span id="cb9-49"><a href="#cb9-49"></a> <span class="kw">auto</span> <span class="kw">operator</span><span class="op">==(</span>S <span class="kw">const</span><span class="op">&</span> s<span class="op">)</span> <span class="kw">const</span> <span class="op">-></span> <span class="dt">bool</span> <span class="op">{</span></span>
<span id="cb9-50"><a href="#cb9-50"></a> <span class="cf">return</span> it <span class="op">==</span> s;</span>
<span id="cb9-51"><a href="#cb9-51"></a> <span class="op">}</span></span>
<span id="cb9-52"><a href="#cb9-52"></a></span>
<span id="cb9-53"><a href="#cb9-53"></a> <span class="kw">auto</span> <span class="kw">operator</span><span class="op"><=>(</span>basic_const_iterator <span class="kw">const</span><span class="op">&</span> rhs<span class="op">)</span> <span class="kw">const</span> <span class="kw">requires</span> std<span class="op">::</span>random_access_iterator<span class="op"><</span>It<span class="op">></span> <span class="op">{</span></span>
<span id="cb9-54"><a href="#cb9-54"></a> <span class="cf">return</span> it <span class="op"><=></span> rhs;</span>
<span id="cb9-55"><a href="#cb9-55"></a> <span class="op">}</span></span>
<span id="cb9-56"><a href="#cb9-56"></a></span>
<span id="cb9-57"><a href="#cb9-57"></a> <span class="kw">template</span> <span class="op"><</span><em>different-from</em><span class="op"><</span>basic_const_iterator<span class="op">></span> Rhs<span class="op">></span></span>
<span id="cb9-58"><a href="#cb9-58"></a> <span class="kw">requires</span> std<span class="op">::</span>random_access_iterator<span class="op"><</span>It<span class="op">></span></span>
<span id="cb9-59"><a href="#cb9-59"></a> <span class="kw">and</span> std<span class="op">::</span>totally_ordered_with<span class="op"><</span>It, Rhs<span class="op">></span></span>
<span id="cb9-60"><a href="#cb9-60"></a> <span class="kw">auto</span> <span class="kw">operator</span><span class="op"><=>(</span>Rhs <span class="kw">const</span><span class="op">&</span> rhs<span class="op">)</span> <span class="kw">const</span> <span class="op">{</span></span>
<span id="cb9-61"><a href="#cb9-61"></a> <span class="cf">if</span> <span class="kw">constexpr</span> <span class="op">(</span>std<span class="op">::</span>three_way_comparable_with<span class="op"><</span>It, Rhs<span class="op">>)</span> <span class="op">{</span></span>
<span id="cb9-62"><a href="#cb9-62"></a> <span class="cf">return</span> it <span class="op"><=></span> rhs;</span>
<span id="cb9-63"><a href="#cb9-63"></a> <span class="op">}</span> <span class="cf">else</span> <span class="cf">if</span> <span class="kw">constexpr</span> <span class="op">(</span>std<span class="op">::</span>sized_sentinel_for<span class="op"><</span>Rhs, It<span class="op">>)</span> <span class="op">{</span></span>
<span id="cb9-64"><a href="#cb9-64"></a> <span class="cf">return</span> <span class="op">(</span>it <span class="op">-</span> rhs<span class="op">)</span> <span class="op"><=></span> <span class="dv">0</span>;</span>
<span id="cb9-65"><a href="#cb9-65"></a> <span class="op">}</span> <span class="cf">else</span> <span class="op">{</span></span>
<span id="cb9-66"><a href="#cb9-66"></a> <span class="cf">if</span> <span class="op">(</span>it <span class="op"><</span> rhs<span class="op">)</span> <span class="cf">return</span> std<span class="op">::</span>strong_ordering<span class="op">::</span>less;</span>
<span id="cb9-67"><a href="#cb9-67"></a> <span class="cf">if</span> <span class="op">(</span>rhs <span class="op"><</span> it<span class="op">)</span> <span class="cf">return</span> std<span class="op">::</span>strong_ordering<span class="op">::</span>greater;</span>
<span id="cb9-68"><a href="#cb9-68"></a> <span class="cf">return</span> std<span class="op">::</span>strong_ordering<span class="op">::</span>equal;</span>
<span id="cb9-69"><a href="#cb9-69"></a> <span class="op">}</span></span>
<span id="cb9-70"><a href="#cb9-70"></a> <span class="op">}</span></span>
<span id="cb9-71"><a href="#cb9-71"></a></span>
<span id="cb9-72"><a href="#cb9-72"></a> <span class="kw">template</span> <span class="op"><</span>std<span class="op">::</span>sized_sentinel_for<span class="op"><</span>It<span class="op">></span> S<span class="op">></span></span>
<span id="cb9-73"><a href="#cb9-73"></a> <span class="kw">auto</span> <span class="kw">operator</span><span class="op">-(</span>S <span class="kw">const</span><span class="op">&</span> s<span class="op">)</span> <span class="kw">const</span> <span class="op">-></span> std<span class="op">::</span>iter_difference_t<span class="op"><</span>It<span class="op">></span> <span class="op">{</span></span>
<span id="cb9-74"><a href="#cb9-74"></a> <span class="cf">return</span> it <span class="op">-</span> s;</span>
<span id="cb9-75"><a href="#cb9-75"></a> <span class="op">}</span></span>
<span id="cb9-76"><a href="#cb9-76"></a></span>
<span id="cb9-77"><a href="#cb9-77"></a> <span class="kw">template</span> <span class="op"><</span><em>different-from</em><span class="op"><</span>basic_const_iterator<span class="op">></span> S<span class="op">></span></span>
<span id="cb9-78"><a href="#cb9-78"></a> <span class="kw">requires</span> std<span class="op">::</span>sized_sentinel_for<span class="op"><</span>S, It<span class="op">></span></span>
<span id="cb9-79"><a href="#cb9-79"></a> <span class="kw">friend</span> <span class="kw">auto</span> <span class="kw">operator</span><span class="op">-(</span>S <span class="kw">const</span><span class="op">&</span> s, basic_const_iterator <span class="kw">const</span><span class="op">&</span> rhs<span class="op">)</span> <span class="op">-></span> std<span class="op">::</span>iter_difference_t<span class="op"><</span>It<span class="op">></span> <span class="op">{</span></span>
<span id="cb9-80"><a href="#cb9-80"></a> <span class="cf">return</span> s <span class="op">-</span> rhs<span class="op">.</span>it;</span>
<span id="cb9-81"><a href="#cb9-81"></a> <span class="op">}</span></span>
<span id="cb9-82"><a href="#cb9-82"></a></span>
<span id="cb9-83"><a href="#cb9-83"></a> <span class="kw">auto</span> base<span class="op">()</span> <span class="op">-></span> It<span class="op">&</span> <span class="op">{</span> <span class="cf">return</span> it; <span class="op">}</span></span>
<span id="cb9-84"><a href="#cb9-84"></a> <span class="kw">auto</span> base<span class="op">()</span> <span class="kw">const</span> <span class="op">-></span> It <span class="kw">const</span><span class="op">&</span> <span class="op">{</span> <span class="cf">return</span> it; <span class="op">}</span></span>
<span id="cb9-85"><a href="#cb9-85"></a><span class="op">}</span>;</span>
<span id="cb9-86"><a href="#cb9-86"></a></span>
<span id="cb9-87"><a href="#cb9-87"></a><span class="kw">template</span> <span class="op"><</span><span class="kw">typename</span> T, std<span class="op">::</span>common_with<span class="op"><</span>T<span class="op">></span> U<span class="op">></span></span>
<span id="cb9-88"><a href="#cb9-88"></a><span class="kw">struct</span> std<span class="op">::</span>common_type<span class="op"><</span>basic_const_iterator<span class="op"><</span>T<span class="op">></span>, U<span class="op">></span> <span class="op">{</span></span>
<span id="cb9-89"><a href="#cb9-89"></a> <span class="kw">using</span> type <span class="op">=</span> basic_const_iterator<span class="op"><</span>std<span class="op">::</span>common_type_t<span class="op"><</span>T, U<span class="op">>></span>;</span>
<span id="cb9-90"><a href="#cb9-90"></a><span class="op">}</span>;</span>
<span id="cb9-91"><a href="#cb9-91"></a><span class="kw">template</span> <span class="op"><</span><span class="kw">typename</span> T, std<span class="op">::</span>common_with<span class="op"><</span>T<span class="op">></span> U<span class="op">></span></span>
<span id="cb9-92"><a href="#cb9-92"></a><span class="kw">struct</span> std<span class="op">::</span>common_type<span class="op"><</span>U, basic_const_iterator<span class="op"><</span>T<span class="op">>></span> <span class="op">{</span></span>
<span id="cb9-93"><a href="#cb9-93"></a> <span class="kw">using</span> type <span class="op">=</span> basic_const_iterator<span class="op"><</span>std<span class="op">::</span>common_type_t<span class="op"><</span>T, U<span class="op">>></span>;</span>
<span id="cb9-94"><a href="#cb9-94"></a><span class="op">}</span>;</span>
<span id="cb9-95"><a href="#cb9-95"></a><span class="kw">template</span> <span class="op"><</span><span class="kw">typename</span> T, std<span class="op">::</span>common_with<span class="op"><</span>T<span class="op">></span> U<span class="op">></span></span>
<span id="cb9-96"><a href="#cb9-96"></a><span class="kw">struct</span> std<span class="op">::</span>common_type<span class="op"><</span>basic_const_iterator<span class="op"><</span>T<span class="op">></span>, basic_const_iterator<span class="op"><</span>U<span class="op">>></span> <span class="op">{</span></span>
<span id="cb9-97"><a href="#cb9-97"></a> <span class="kw">using</span> type <span class="op">=</span> basic_const_iterator<span class="op"><</span>std<span class="op">::</span>common_type_t<span class="op"><</span>T, U<span class="op">>></span>;</span>
<span id="cb9-98"><a href="#cb9-98"></a><span class="op">}</span>;</span></code></pre></div>
<p>Since the above implementation satisfies the requirements for a <code class="sourceCode cpp">sentinel</code> where appropriate, we can complete our implementation by providing a <code class="sourceCode cpp">make_const_sentinel</code> to mirror the <code class="sourceCode cpp">make_const_iterator</code> shown earlier:</p>
<div class="sourceCode" id="cb10"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb10-1"><a href="#cb10-1"></a><span class="kw">template</span> <span class="op"><</span><span class="kw">typename</span> S<span class="op">></span></span>
<span id="cb10-2"><a href="#cb10-2"></a><span class="kw">constexpr</span> <span class="kw">auto</span> make_const_sentinel<span class="op">(</span>S s<span class="op">)</span> <span class="op">{</span></span>
<span id="cb10-3"><a href="#cb10-3"></a> <span class="cf">if</span> <span class="kw">constexpr</span> <span class="op">(</span>std<span class="op">::</span>input_iterator<span class="op"><</span>S<span class="op">>)</span> <span class="op">{</span></span>
<span id="cb10-4"><a href="#cb10-4"></a> <span class="co">// the sentinel here is an iterator in its own right, so we need to (possibly) wrap it the same way</span></span>
<span id="cb10-5"><a href="#cb10-5"></a> <span class="cf">return</span> make_const_iterator<span class="op">(</span>std<span class="op">::</span>move<span class="op">(</span>s<span class="op">))</span>;</span>
<span id="cb10-6"><a href="#cb10-6"></a> <span class="op">}</span> <span class="cf">else</span> <span class="op">{</span></span>
<span id="cb10-7"><a href="#cb10-7"></a> <span class="cf">return</span> s;</span>
<span id="cb10-8"><a href="#cb10-8"></a> <span class="op">}</span></span>
<span id="cb10-9"><a href="#cb10-9"></a><span class="op">}</span></span></code></pre></div>
<p>We could take the iterator type as a template parameter to enforce that <code class="sourceCode cpp">S</code> satisfies <code class="sourceCode cpp">sentinel_for<span class="op"><</span>I<span class="op">></span></code>, but this function is only used as a building block of an algorithm that would already enforce this, so it’s probably not necessary.</p>
<h2 data-number="3.4" id="better-algorithms-for-stdrangescbegin-and-stdrangesend"><span class="header-section-number">3.4</span> Better Algorithms for <code class="sourceCode cpp">std<span class="op">::</span>ranges<span class="op">::</span>cbegin</code> and <code class="sourceCode cpp">std<span class="op">::</span>ranges<span class="op">::</span>end</code><a href="#better-algorithms-for-stdrangescbegin-and-stdrangesend" class="self-link"></a></h2>
<p><code class="sourceCode cpp">std<span class="op">::</span>ranges<span class="op">::</span>cbegin</code> today (<span>26.3.4 <a href="https://wg21.link/range.access.cbegin">[range.access.cbegin]</a></span>) unconditionally calls <code class="sourceCode cpp">std<span class="op">::</span>ranges<span class="op">::</span>begin</code>. Similarly, <code class="sourceCode cpp">std<span class="op">::</span>cbegin</code> today (<span>25.7 <a href="https://wg21.link/iterator.range">[iterator.range]</a></span>) unconditionally calls <code class="sourceCode cpp">std<span class="op">::</span>begin</code>. The status quo in the library is that nothing anywhere invokes <em>member</em> <code class="sourceCode cpp">cbegin</code>. The goal is to provide a constant iterator version of <code class="sourceCode cpp">begin<span class="op">()</span></code> — we have not had a customization point for this facility in the past and we can achieve this goal without having to add a customization point for the future.</p>
<p>With the above pieces, we implement a <code class="sourceCode cpp">ranges<span class="op">::</span>cbegin</code> and <code class="sourceCode cpp">ranges<span class="op">::</span>end</code> to ensure that we get a constant iterator (see full implementation <span class="citation" data-cites="const-impl">[<a href="#ref-const-impl" role="doc-biblioref">const-impl</a>]</span>, complete with many tests):</p>
<div class="sourceCode" id="cb11"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb11-1"><a href="#cb11-1"></a><span class="kw">inline</span> <span class="kw">constexpr</span> <span class="kw">auto</span> possibly_const <span class="op">=</span> <span class="op">[]<</span>std<span class="op">::</span>ranges<span class="op">::</span>range R<span class="op">>(</span>R<span class="op">&</span> r<span class="op">)</span> <span class="op">-></span> <span class="kw">auto</span><span class="op">&</span> <span class="op">{</span></span>
<span id="cb11-2"><a href="#cb11-2"></a> <span class="co">// we only cast to const if it is meaningful to do so</span></span>
<span id="cb11-3"><a href="#cb11-3"></a> <span class="cf">if</span> <span class="kw">constexpr</span> <span class="op">(</span><em>constant-range</em><span class="op"><</span>R <span class="kw">const</span><span class="op">></span> <span class="kw">and</span> <span class="kw">not</span> <em>constant-range</em><span class="op"><</span>R<span class="op">>)</span> <span class="op">{</span></span>
<span id="cb11-4"><a href="#cb11-4"></a> <span class="cf">return</span> <span class="kw">const_cast</span><span class="op"><</span>R <span class="kw">const</span><span class="op">&>(</span>r<span class="op">)</span>;</span>
<span id="cb11-5"><a href="#cb11-5"></a> <span class="op">}</span> <span class="cf">else</span> <span class="op">{</span></span>
<span id="cb11-6"><a href="#cb11-6"></a> <span class="cf">return</span> r;</span>
<span id="cb11-7"><a href="#cb11-7"></a> <span class="op">}</span></span>
<span id="cb11-8"><a href="#cb11-8"></a><span class="op">}</span>;</span>
<span id="cb11-9"><a href="#cb11-9"></a></span>
<span id="cb11-10"><a href="#cb11-10"></a><span class="kw">inline</span> <span class="kw">constexpr</span> <span class="kw">auto</span> cbegin <span class="op">=</span> first_of<span class="op">(</span></span>
<span id="cb11-11"><a href="#cb11-11"></a> <span class="co">// 1. non-borrowed rvalue</span></span>
<span id="cb11-12"><a href="#cb11-12"></a> delete_if_nonborrowed_rvalue,</span>
<span id="cb11-13"><a href="#cb11-13"></a> <span class="co">// 2. possibly-wrapped begin of possibly-const-range r</span></span>
<span id="cb11-14"><a href="#cb11-14"></a> <span class="op">[](</span>std<span class="op">::</span>ranges<span class="op">::</span>range <span class="kw">auto</span><span class="op">&&</span> r<span class="op">)</span></span>
<span id="cb11-15"><a href="#cb11-15"></a> RETURNS<span class="op">(</span>make_const_iterator<span class="op">(</span>std<span class="op">::</span>ranges<span class="op">::</span>begin<span class="op">(</span>possibly_const<span class="op">(</span>r<span class="op">))))</span></span>
<span id="cb11-16"><a href="#cb11-16"></a><span class="op">)</span>;</span>
<span id="cb11-17"><a href="#cb11-17"></a></span>
<span id="cb11-18"><a href="#cb11-18"></a><span class="kw">inline</span> <span class="kw">constexpr</span> <span class="kw">auto</span> cend <span class="op">=</span> first_of<span class="op">(</span></span>
<span id="cb11-19"><a href="#cb11-19"></a> <span class="co">// 1. non-borrowed rvalue</span></span>
<span id="cb11-20"><a href="#cb11-20"></a> delete_if_nonborrowed_rvalue,</span>