Repository navigation
Expand file tree
/
Copy pathlib-intro.tex
More file actions
2760 lines (2359 loc) · 99.3 KB
/
Copy pathlib-intro.tex
File metadata and controls
2760 lines (2359 loc) · 99.3 KB
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
%!TEX root = std.tex
\rSec0[library]{Library introduction}
\rSec1[library.general]{General}
\pnum
This Clause describes the contents of the
\term{\Cpp standard library},
\indextext{library!C++ standard}%
how a well-formed \Cpp program makes use of the library, and
how a conforming implementation may provide the entities in the library.
\pnum
The following subclauses describe the definitions~(\ref{definitions}), method of
description~(\ref{description}), and organization~(\ref{organization}) of the
library. Clause~\ref{requirements}, Clauses~\ref{\firstlibchapter}
through~\ref{\lastlibchapter}, and Annex~\ref{depr} specify the contents of the
library, as well as library requirements and constraints on both well-formed
\Cpp programs and conforming implementations.
\pnum
Detailed specifications for each of the components in the library are in
Clauses~\ref{\firstlibchapter}--\ref{\lastlibchapter}, as shown in
Table~\ref{tab:library.categories}.
\begin{libsumtabbase}{Library categories}{tab:library.categories}{Clause}{Category}
\ref{language.support} & & Language support library \\
\ref{diagnostics} & & Diagnostics library \\
\ref{utilities} & & General utilities library \\
\ref{strings} & & Strings library \\
\ref{localization} & & Localization library \\
\ref{containers} & & Containers library \\
\ref{iterators} & & Iterators library \\
\ref{algorithms} & & Algorithms library \\
\ref{numerics} & & Numerics library \\
\ref{input.output} & & Input/output library \\
\ref{re} & & Regular expressions library \\
\ref{atomics} & & Atomic operations library \\
\ref{thread} & & Thread support library \\
\end{libsumtabbase}
\pnum
The language support library (Clause~\ref{language.support}) provides components that are
required by certain parts of the \Cpp language, such as memory allocation~(\ref{expr.new},
\ref{expr.delete}) and exception processing (Clause~\ref{except}).
\pnum
The diagnostics library (Clause~\ref{diagnostics}) provides a consistent framework for
reporting errors in a \Cpp program, including predefined exception classes.
\pnum
The general utilities library (Clause~\ref{utilities}) includes components used
by other library elements, such as a predefined storage allocator for dynamic
storage management~(\ref{basic.stc.dynamic}), and components used
as infrastructure
in \Cpp programs,
such as a tuples, function wrappers, and time facilities.
\pnum
The strings library (Clause~\ref{strings}) provides support for manipulating text represented
as sequences of type
\tcode{char},
sequences of type
\tcode{char16_t},
sequences of type
\tcode{char32_t},
sequences of type
\tcode{wchar_t},
and sequences of any other character-like type.
\pnum
The localization library (Clause~\ref{localization}) provides extended internationalization
support for text processing.
\pnum
The containers (Clause~\ref{containers}), iterators (Clause~\ref{iterators}),
and algorithms (Clause~\ref{algorithms}) libraries provide a \Cpp program with access
to a subset of the most widely used algorithms and data structures.
\pnum
The numerics library (Clause~\ref{numerics}) provides
numeric algorithms and complex number components that extend support for numeric processing.
The
\tcode{valarray}
component provides support for
\textit{n}-at-a-time
processing,
potentially implemented as parallel operations on platforms that support such processing.
The random number component provides facilities for generating pseudo-random numbers.
\pnum
The input/output library (Clause~\ref{input.output}) provides the
\tcode{iostream}
components that are the primary mechanism for \Cpp program input and output.
They can be used with other elements of the library, particularly
strings, locales, and iterators.
\pnum
The regular expressions library (Clause~\ref{re}) provides regular expression matching and searching.
\pnum
The atomic operations library (Clause~\ref{atomics}) allows more fine-grained
concurrent access to shared data than is possible with locks.
\pnum
The thread support library (Clause~\ref{thread}) provides components to create
and manage threads, including mutual exclusion and interthread communication.
\rSec1[library.c]{The C standard library}
\pnum
The \Cpp standard library also makes available the facilities of the C standard library,
\indextext{library!C standard}%
suitably adjusted to ensure static type safety.
\pnum
The descriptions of many library functions rely on the C standard library for
the signatures and semantics of those functions. In all such cases, any use of
the \tcode{restrict} qualifier shall be omitted.
\rSec1[definitions]{Definitions}
\definition{arbitrary-positional stream}{defns.arbitrary.stream}
\indexdefn{stream!arbitrary-positional}%
a stream (described in Clause~\ref{input.output}) that can seek to any integral position within
the length of the stream\\
\enternote Every arbitrary-positional stream is also a repositional stream. \exitnote
\definition{block}{defns.block}
\indexdefn{block}%
place a thread in the blocked state
\definition{blocked thread}{defns.blocked}
\indexdefn{thread, blocked}%
a thread that is waiting for some condition (other than the availability of a processor) to be
satisfied before it can continue execution\footnote{This definition is taken from POSIX.}
\definition{character}{defns.character}
\indexdefn{character}%
<Clauses~\ref{strings}, \ref{localization}, \ref{input.output}, and~\ref{re}>
any object which,
when treated sequentially,
can represent text\\
\enternote
The term does not mean only
\tcode{char},
\tcode{char16_t},
\tcode{char32_t},
and
\tcode{wchar_t}
objects,
but any value that can be represented by a type
that provides the definitions specified in these Clauses.
\exitnote
\definition{character container type}{defns.character.container}
\indexdefn{type!character container}%
a class or a type used to
represent a
\term{character}\\
\enternote
It is used for one of the template parameters of the string,
iostream, and regular expression class templates.
A character container type is a POD~(\ref{basic.types}) type.
\exitnote
\definition{comparison function}{defns.comparison}
\indexdefn{function!comparison}%
an operator function~(\ref{over.oper}) for any of the equality~(\ref{expr.eq}) or
relational~(\ref{expr.rel}) operators
\definition{component}{defns.component}
\indexdefn{component}%
a group of library entities directly related as members, parameters, or
return types\\
\enternote
For example, the class template
\tcode{basic_string}
and the non-member
function templates
that operate on
strings are referred to as the
\term{string component}.
\exitnote
\definition{deadlock}{defns.deadlock}
\indexdefn{deadlock}%
one or more threads are unable to continue execution because each is
blocked waiting for one or more of the others to satisfy some condition
\definition{default behavior}{defns.default.behavior.impl}
\indexdefn{behavior!default}%
<implementation>
any specific behavior provided by the implementation,
within the scope of the
\term{required behavior}
\definition{default behavior}{defns.default.behavior.func}
\indexdefn{behavior!default}%
<specification>
a description of
\term{replacement function}
and
\term{handler function}
semantics
\definition{handler function}{defns.handler}
\indexdefn{function!handler}%
a
\term{non-reserved function}
whose definition may be provided by a \Cpp program\\
\enternote
A \Cpp program may designate a handler function at various points in its execution by
supplying a pointer to the function when calling any of the library functions that install
handler functions (Clause~\ref{language.support}).
\exitnote
\definition{iostream class templates}{defns.iostream.templates}
templates, defined in Clause~\ref{input.output},
that take two template arguments\\
\enternote
The arguments are named
\tcode{charT}
and
\tcode{traits}.
The argument
\tcode{charT}
is a character container class,
and the argument
\tcode{traits}
is a class which defines additional characteristics and functions
of the character type represented by
\tcode{charT}
necessary to implement the iostream class templates.
\exitnote
\definition{modifier function}{defns.modifier}
\indexdefn{function!modifier}%
a class member function~(\ref{class.mfct}) other than a constructor,
assignment operator, or destructor
that alters the state of an object of the class
\definition{move construction}{defns.move.constr}
\indexdefn{construction!move}%
direct-initialization of an object of some type with an rvalue of the same type
\definition{move assignment}{defns.move.assign}
\indexdefn{assignment!move}%
assignment of an rvalue of some object type to a modifiable lvalue of the same type
\definition{object state}{defns.obj.state}
\indexdefn{state!object}%
the current value of all non-static class members of an object~(\ref{class.mem})\\
\enternote
The state of an object can be obtained by using one or more
\term{observer functions}.
\exitnote
\definition{NTCTS}{defns.ntcts}
\indexdefn{NTCTS}%
\indexdefn{string!null-terminated character~type}%
a sequence of values that have
\term{character type}
that precede the terminating null character type
value
\tcode{charT()}
\definition{observer function}{defns.observer}
\indexdefn{function!observer}%
a class member function~(\ref{class.mfct}) that accesses the state of an object of the class
but does not alter that state\\
\enternote
Observer functions are specified as
\tcode{const}
member functions~(\ref{class.this}).
\exitnote
\definition{referenceable type}{defns.referenceable}
\indexdefn{type!referenceable}
An object type, a function type that does not have cv-qualifiers or a
\grammarterm{ref-qualifier}, or a reference type.
\enternote The term describes a type to which a reference can be created,
including reference types. \exitnote
\definition{replacement function}{defns.replacement}
\indexdefn{function!replacement}%
a
\term{non-reserved function}
whose definition is provided by a \Cpp program\\
\enternote
Only one definition for such a function is in effect for the duration of the program's
execution, as the result of creating the program~(\ref{lex.phases}) and resolving the
definitions of all translation units~(\ref{basic.link}).
\exitnote
\definition{repositional stream}{defns.repositional.stream}
\indexdefn{stream!repositional}%
a stream (described in Clause~\ref{input.output}) that can seek to a position that was
previously encountered
\definition{required behavior}{defns.required.behavior}
\indexdefn{behavior!required}%
a description of
\term{replacement function}
and
\term{handler function}
semantics
applicable to both the behavior provided by the implementation and
the behavior of any such function definition in the program\\
\enternote
If such a function defined in a \Cpp program fails to meet the required
behavior when it executes, the behavior is undefined.%
\indextext{undefined}
\exitnote
\definition{reserved function}{defns.reserved.function}
\indexdefn{function!reserved}%
a function, specified as part of the \Cpp standard library, that must be defined by the
implementation\\
\enternote
If a \Cpp program provides a definition for any reserved function, the results are undefined.%
\indextext{undefined}
\exitnote
\definition{stable algorithm}{defns.stable}
\indexdefn{algorithm!stable}%
\indexdefn{stable algorithm}%
an algorithm that preserves, as appropriate to the particular algorithm, the order
of elements\\
\enternote Requirements for stable algorithms are given in~\ref{algorithm.stable}. \exitnote
\definition{traits class}{defns.traits}
\indexdefn{traits}%
a class that encapsulates a set of types and functions necessary for class templates and
function templates to manipulate objects of types for which they are instantiated\\
\enternote
Traits classes defined in Clauses~\ref{strings}, \ref{localization} and~\ref{input.output} are
\term{character traits}, which provide the character handling support needed by the string and
iostream classes.
\exitnote
\definition{unblock}{defns.unblock}
\indexdefn{unblock}%
place a thread in the unblocked state
\definition{valid but unspecified state}{defns.valid}
\indexdefn{valid but unspecified state}%
an object state that is not specified except that the object's invariants are
met and operations on the object behave as specified for its type\\
\enterexample If an object \tcode{x} of type \tcode{std::vector<int>} is in a
valid but unspecified state, \tcode{x.empty()} can be called unconditionally,
and \tcode{x.front()} can be called only if \tcode{x.empty()} returns
\tcode{false}. \exitexample
\rSec1[defns.additional]{Additional definitions}
\pnum
\ref{intro.defs} defines additional terms used elsewhere in this International Standard.
\rSec1[description]{Method of description (Informative)}
\pnum
This subclause describes the conventions used to specify the \Cpp standard
library. \ref{structure} describes the structure of the normative
Clauses~\ref{\firstlibchapter} through~\ref{\lastlibchapter} and
Annex~\ref{depr}. \ref{conventions} describes other editorial conventions.
\rSec2[structure]{Structure of each clause}
\rSec3[structure.elements]{Elements}
\pnum
Each library clause contains the following elements, as applicable:\footnote{To
save space, items that do not apply to a Clause are omitted.
For example, if a Clause does not specify any requirements,
there will be no ``Requirements'' subclause.}
\begin{itemize}
\item Summary
\item Requirements
\item Detailed specifications
\item References to the Standard C library
\end{itemize}
\rSec3[structure.summary]{Summary}
\pnum
The Summary provides a synopsis of the category, and introduces the first-level subclauses.
Each subclause also provides a summary, listing the headers specified in the
subclause and the library entities provided in each header.
\pnum
Paragraphs labeled ``Note(s):'' or ``Example(s):'' are informative, other paragraphs
are normative.
\pnum
The contents of the summary and the detailed specifications include:
\begin{itemize}
\item macros
\item values
\item types
\item classes and class templates
\item functions and function templates
\item objects
\end{itemize}
\rSec3[structure.requirements]{Requirements}
\pnum
\indextext{requirements}%
Requirements describe constraints that shall be met by a \Cpp program that extends the standard library.
Such extensions are generally one of the following:
\begin{itemize}
\item Template arguments
\item Derived classes
\item Containers, iterators, and algorithms that meet an interface convention
\end{itemize}
\pnum
The string and iostream components use an explicit representation of operations
required of template arguments. They use a class template \tcode{char_traits} to
define these constraints.
\pnum
Interface convention requirements are stated as generally as possible. Instead
of stating ``class X has to define a member function \tcode{operator++()},'' the
interface requires ``for any object \tcode{x} of class \tcode{X}, \tcode{++x} is
defined.'' That is, whether the operator is a member is unspecified.
\pnum
Requirements are stated in terms of well-defined expressions that define valid terms of
the types that satisfy the requirements. For every set of well-defined expression
requirements there is a table that specifies an initial set of the valid expressions and
their semantics. Any generic algorithm (Clause~\ref{algorithms}) that uses the
well-defined expression requirements is described in terms of the valid expressions for
its formal type parameters.
\pnum
Template argument requirements are sometimes referenced by name.
See~\ref{type.descriptions}.
\pnum
In some cases the semantic requirements are presented as \Cpp code.
Such code is intended as a
specification of equivalence of a construct to another construct, not
necessarily as the way the construct
must be implemented.\footnote{Although in some cases the code given is
unambiguously the optimum implementation.}
\rSec3[structure.specifications]{Detailed specifications}
\pnum
The detailed specifications each contain the following elements:%
\begin{itemize}
\item name and brief description
\item synopsis (class definition or function prototype, as appropriate)
\item restrictions on template arguments, if any
\item description of class invariants
\item description of function semantics
\end{itemize}
\pnum
Descriptions of class member functions follow the order (as
appropriate):\footnote{To save space, items that do not apply to a class are omitted.
For example, if a class does not specify any comparison functions, there
will be no ``Comparison functions'' subclause.}
\begin{itemize}
\item constructor(s) and destructor
\item copying, moving \& assignment functions
\item comparison functions
\item modifier functions
\item observer functions
\item operators and other non-member functions
\end{itemize}
\pnum
Descriptions of function semantics contain the following elements (as
appropriate):\footnote{To save space, items that do not apply to a function are omitted.
For example, if a function does not specify any
further
preconditions, there will be no ``Requires'' paragraph.}
\begin{itemize}
\item \requires the preconditions for calling the function
\item \effects the actions performed by the function
\item \sync the synchronization operations~(\ref{intro.multithread}) applicable to the function
\item \postconditions the observable results established by the function
\item \returns a description of the value(s) returned by the function
\item \throws any exceptions thrown by the function, and the conditions that would cause the exception
\item \complexity the time and/or space complexity of the function
\item \notes additional semantic constraints on the function
\item \errors the error conditions for error codes reported by the function.
\item \realnotes non-normative comments about the function
\end{itemize}
\pnum
Whenever the \effects element specifies that the semantics of some function
\tcode{F} are \techterm{Equivalent to} some code sequence, then the various elements are
interpreted as follows. If \tcode{F}'s semantics specifies a \requires element, then
that requirement is logically imposed prior to the \techterm{equivalent-to} semantics.
Next, the semantics of the code sequence are determined by the \requires, \effects,
\postconditions, \returns, \throws, \complexity, \notes, \errors, and \realnotes
specified for the function invocations contained in the code sequence. The value
returned from \tcode{F} is specified by \tcode{F}'s \returns element, or if \tcode{F}
has no \returns element, a non-\tcode{void} return from \tcode{F} is specified by the
\returns elements in the code sequence. If \tcode{F}'s semantics contains a \throws,
\postconditions, or \complexity element, then that supersedes any occurrences of that
element in the code sequence.
\pnum
For non-reserved replacement and handler functions,
Clause~\ref{language.support} specifies two behaviors for the functions in question:
their required and default behavior.
The
\term{default behavior}
describes a function definition provided by the implementation.
\indextext{behavior!default}%
The
\term{required behavior}
describes the semantics of a function definition provided by
\indextext{behavior!required}%
either the implementation or a \Cpp program.
Where no distinction is explicitly made in the description, the
behavior described is the required behavior.
\pnum
If the formulation of a complexity requirement calls for a negative number of
operations, the actual requirement is zero operations.\footnote{This simplifies
the presentation of complexity requirements in some cases.}
\pnum
Complexity requirements specified in the library clauses are upper bounds,
and implementations that provide better complexity guarantees satisfy
the requirements.
\pnum
Error conditions specify conditions where a function may fail. The conditions
are listed, together with a suitable explanation, as the \tcode{enum class errc}
constants~(\ref{syserr}).
\rSec3[structure.see.also]{C library}
\pnum
Paragraphs labeled ``\xref'' contain cross-references to the relevant portions
of this International Standard and the ISO C standard,
which is incorporated into this International Standard by reference.
\rSec2[conventions]{Other conventions}
\indextext{conventions}%
\pnum
This subclause describes several editorial conventions used to describe the contents
of the \Cpp standard library.
These conventions are for describing
implementation-defined types~(\ref{type.descriptions}),
and member functions~(\ref{functions.within.classes}).
\rSec3[type.descriptions]{Type descriptions}
\rSec4[type.descriptions.general]{General}
\pnum
The Requirements subclauses may describe names that are used to specify
constraints on template arguments.\footnote{Examples
from~\ref{utility.requirements} include:
\tcode{EqualityComparable},
\tcode{LessThanComparable},
\tcode{CopyConstructible}.
Examples from~\ref{iterator.requirements} include:
\tcode{InputIterator},
\tcode{ForwardIterator},
\tcode{Function},
\tcode{Predicate}.}
These names are used in library Clauses
to describe the types that
may be supplied as arguments by a \Cpp program when instantiating template components from
the library.
\pnum
Certain types defined in Clause~\ref{input.output} are used to describe implementation-defined types.
\indextext{types!implementation-defined}%
They are based on other types, but with added constraints.
\rSec4[enumerated.types]{Enumerated types}
\pnum
Several types defined in Clause~\ref{input.output} are
\term{enumerated types}.
\indextext{type!enumerated}%
Each enumerated type may be implemented as an enumeration or as a synonym for
an enumeration.\footnote{Such as an integer type, with constant integer
values~(\ref{basic.fundamental}).}
\pnum
The enumerated type \term{enumerated} can be written:
\begin{codeblock}
enum @\term{enumerated}@ { @\term{V0}@, @\term{V1}@, @\term{V2}@, @\term{V3}@, ..... };
static const @\term{enumerated C0}@ (@\term{V0}@);
static const @\term{enumerated C1}@ (@\term{V1}@);
static const @\term{enumerated C2}@ (@\term{V2}@);
static const @\term{enumerated C3}@ (@\term{V3}@);
.....
\end{codeblock}
\pnum
Here, the names \term{C0}, \term{C1}, etc. represent
\term{enumerated elements}
for this particular enumerated type.
\indextext{type!enumerated}%
All such elements have distinct values.
\rSec4[bitmask.types]{Bitmask types}
\pnum
Several types defined in Clauses~\ref{\firstlibchapter} through~\ref{\lastlibchapter}
and Annex~\ref{depr} are
\term{bitmask types}.
\indextext{type!bitmask}%
Each bitmask type can be implemented as an
enumerated type that overloads certain operators, as an integer type,
or as a
\tcode{bitset}~(\ref{template.bitset}).
\indextext{type!enumerated}%
\pnum
The bitmask type \term{bitmask} can be written:
\begin{codeblock}
// For exposition only.
// \tcode{int_type} is an integral type capable of
// representing all values of the bitmask type.
enum @\term{bitmask}@ : int_type {
@\term{V0}@ = 1 << 0, @\term{V1}@ = 1 << 1, @\term{V2}@ = 1 << 2, @\term{V3}@ = 1 << 3, .....
};
constexpr @\term{bitmask C0}@(@\term{V0}{}@);
constexpr @\term{bitmask C1}@(@\term{V1}{}@);
constexpr @\term{bitmask C2}@(@\term{V2}{}@);
constexpr @\term{bitmask C3}@(@\term{V3}{}@);
.....
constexpr @\term{bitmask}{}@ operator&(@\term{bitmask}{}@ X, @\term{bitmask}{}@ Y) {
return static_cast<@\term{bitmask}{}@>(
static_cast<int_type>(X) & static_cast<int_type>(Y));
}
constexpr @\term{bitmask}{}@ operator|(@\term{bitmask}{}@ X, @\term{bitmask}{}@ Y) {
return static_cast<@\term{bitmask}{}@>(
static_cast<int_type>(X) | static_cast<int_type>(Y));
}
constexpr @\term{bitmask}{}@ operator^(@\term{bitmask}{}@ X, @\term{bitmask}{}@ Y){
return static_cast<@\term{bitmask}{}@>(
static_cast<int_type>(X) ^ static_cast<int_type>(Y));
}
constexpr @\term{bitmask}{}@ operator~(@\term{bitmask}{}@ X){
return static_cast<@\term{bitmask}{}@>(~static_cast<int_type>(X));
}
@\term{bitmask}{}@& operator&=(@\term{bitmask}{}@& X, @\term{bitmask}{}@ Y){
X = X & Y; return X;
}
@\term{bitmask}{}@& operator|=(@\term{bitmask}{}@& X, @\term{bitmask}{}@ Y) {
X = X | Y; return X;
}
@\term{bitmask}{}@& operator^=(@\term{bitmask}{}@& X, @\term{bitmask}{}@ Y) {
X = X ^ Y; return X;
}
\end{codeblock}
\pnum
Here, the names \term{C0}, \term{C1}, etc. represent
\term{bitmask elements}
for this particular bitmask type.
\indextext{type!bitmask}%
All such elements have distinct values such that, for any pair \term{Ci}
and \term{Cj}, \term{Ci} \& \term{Ci} is nonzero and
\term{Ci} \& \term{Cj} is zero.
\pnum
The following terms apply to objects and values of
bitmask types:
\begin{itemize}
\item
To
\term{set}
a value \textit{Y} in an object \textit{X}
is to evaluate the expression \textit{X} $|$= \textit{Y}.
\item
To
\term{clear}
a value \textit{Y} in an object
\textit{X} is to evaluate the expression \textit{X} \&= $\sim$\textit{Y}.
\item
The value \textit{Y}
\term{is set}
in the object
\textit{X} if the expression \textit{X} \& \textit{Y} is nonzero.
\end{itemize}
\rSec4[character.seq]{Character sequences}
\pnum
The C standard library makes widespread use
\indextext{library!C standard}%
of characters and character sequences that follow a few uniform conventions:
\begin{itemize}
\item
A
\term{letter}
is any of the 26 lowercase or 26
\indextext{lowercase}%
\indextext{uppercase}%
uppercase letters in the basic execution character set.\footnote{Note that
this definition differs from the definition in ISO C 7.1.1.}
\item
The
\term{decimal-point character}
is the
\indextext{character!decimal-point}%
(single-byte) character used by functions that convert between a (single-byte)
character sequence and a value of one of the floating-point types.
It is used
in the character sequence to denote the beginning of a fractional part.
It is
represented in Clauses~\ref{\firstlibchapter} through~\ref{\lastlibchapter}
and Annex~\ref{depr} by a period,
\indextext{period}%
\tcode{'.'},
which is
also its value in the \tcode{"C"}
locale, but may change during program
execution by a call to
\tcode{setlocale(int, const char*)},\footnote{declared in
\tcode{<clocale>}~(\ref{c.locales}).
\indextext{\idxcode{setlocale}}%
\indexlibrary{\idxcode{setlocale}}%
\indextext{\idxhdr{clocale}}%
\indexlibrary{\idxhdr{clocale}}}
or by a change to a
\tcode{locale}
object, as described in Clauses~\ref{locales} and~\ref{input.output}.
\item
A
\term{character sequence}
is an array object~(\ref{dcl.array}) \textit{A} that
can be declared as
\tcode{\textit{T A}[\textit{N}]},
where \textit{T} is any of the types
\tcode{char},
\tcode{unsigned char},
or
\tcode{signed char}~(\ref{basic.fundamental}), optionally qualified by any combination of
\tcode{const}
or
\tcode{volatile}.
The initial elements of the
array have defined contents up to and including an element determined by some
predicate.
A character sequence can be designated by a pointer value
\textit{S} that points to its first element.
\end{itemize}
\rSec5[byte.strings]{Byte strings}
\pnum
A
\indextext{string!null-terminated byte}%
\indextext{NTBS}%
\term{null-terminated byte string},
or \ntbs,
is a character sequence whose highest-addressed element
with defined content has the value zero
(the
\term{terminating null}
character); no other element in the sequence has the value zero.%
\indextext{\idxhdr{cstring}}%
\indexlibrary{\idxhdr{cstring}}%
\indextext{NTBS}\footnote{Many of the objects manipulated by
function signatures declared in
\tcode{<cstring>}~(\ref{c.strings}) are character sequences or \ntbs{}s.
\indextext{\idxhdr{cstring}}%
\indexlibrary{\idxhdr{cstring}}%
The size of some of these character sequences is limited by
a length value, maintained separately from the character sequence.}
\pnum
The
\term{length} of an \ntbs
is the number of elements that
precede the terminating null character.
\indextext{NTBS}%
An
\term{empty} \ntbs
has a length of zero.
\pnum
The
\term{value} of an \ntbs
is the sequence of values of the
elements up to and including the terminating null character.
\indextext{NTBS}%
\pnum
A
\indextext{NTBS}%
\indextext{NTBS!static}%
\term{static} \ntbs
is an \ntbs with
static storage duration.\footnote{A string literal, such as
\tcode{"abc"},
is a static \ntbs.}
\rSec5[multibyte.strings]{Multibyte strings}
\pnum
A
\indextext{NTBS}%
\indextext{NTMBS}%
\term{null-terminated multibyte string,}
or \ntmbs,
\indextext{string!null-terminated multibyte}%
is an \ntbs that constitutes a
sequence of valid multibyte characters, beginning and ending in the initial
shift state.\footnote{An \ntbs that contains characters only from the
basic execution character set is also an \ntmbs.
Each multibyte character then
consists of a single byte.}
\pnum
A
\term{static} \ntmbs
is an \ntmbs with static storage duration.
\indextext{NTMBS!static}%
\indextext{NTMBS}%
\rSec3[functions.within.classes]{Functions within classes}
\pnum
For the sake of exposition, Clauses~\ref{\firstlibchapter} through~\ref{\lastlibchapter}
and Annex~\ref{depr} do not describe copy/move constructors, assignment
operators, or (non-virtual) destructors with the same apparent
semantics as those that can be generated by default~(\ref{class.ctor}, \ref{class.dtor}, \ref{class.copy}).
\pnum
\indextext{constructor!copy}%
\indextext{operator!assignment}%
\indextext{destructor}%
It is unspecified whether
the implementation provides explicit definitions for such member function
signatures, or for virtual destructors that can be generated by default.
\rSec3[objects.within.classes]{Private members}
\pnum
Clauses~\ref{\firstlibchapter} through~\ref{\lastlibchapter} and
Annex~\ref{depr} do not specify the representation of classes, and intentionally
omit specification of class members~(\ref{class.mem}). An implementation may
define static or non-static class members, or both, as needed to implement the
semantics of the member functions specified in Clauses~\ref{\firstlibchapter}
through~\ref{\lastlibchapter} and Annex~\ref{depr}.
\pnum
Objects of certain classes are sometimes required by the external specifications of
their classes to store data, apparently in member objects. For the sake of exposition,
some subclauses provide representative declarations, and semantic requirements, for
private member objects of classes that meet the external specifications of the classes.
The declarations for such member objects and the definitions of related member types are
followed by a comment that ends with \expos, as in:
\begin{codeblock}
streambuf* sb; // \expos
\end{codeblock}
\pnum
An implementation may use any technique that provides equivalent external behavior.
\rSec1[requirements]{Library-wide requirements}
\pnum
This subclause specifies requirements that apply to the entire \Cpp standard library.
Clauses~\ref{\firstlibchapter} through~\ref{\lastlibchapter} and Annex~\ref{depr}
specify the requirements of individual entities within the library.
\pnum
Requirements specified in terms of interactions between threads do not apply to
programs having only a single thread of execution.
\pnum
Within this subclause, \ref{organization} describes the library's contents and
organization, \ref{using} describes how well-formed \Cpp programs gain access to library
entities,
\ref{utility.requirements} describes constraints on types and functions used with
the \Cpp standard library,
\ref{constraints} describes constraints on well-formed \Cpp programs, and
\ref{conforming} describes constraints on conforming implementations.
\rSec2[organization]{Library contents and organization}
\pnum
\ref{contents} describes the entities defined in the \Cpp standard library.
\ref{headers} lists the standard library headers and some constraints on those headers.
\ref{compliance} lists requirements for a freestanding implementation of the \Cpp
standard library.
\rSec3[contents]{Library contents}
\pnum
The \Cpp standard library provides definitions for the following types of entities:
macros, values, types, templates, classes, functions, objects.
\pnum
All library entities except macros,
\tcode{operator new}
and
\tcode{operator delete}
are defined within the namespace
\tcode{std}
or namespaces nested within namespace
\tcode{std}.\footnote{The C standard library headers (Annex~\ref{depr.c.headers}) also define
names within the global namespace, while the \Cpp headers for C library
facilities~(\ref{headers}) may also define names within the global namespace.}%
\indextext{namespace}
It is unspecified whether names declared in a specific namespace are declared
directly in that namespace or in an inline namespace inside that
namespace.\footnote{This gives implementers freedom to use inline namespaces to
support multiple configurations of the library.}
\pnum
Whenever a name \tcode{x} defined in the standard library is mentioned,
the name \tcode{x} is assumed to be fully qualified as
\tcode{::std::x},
unless explicitly described otherwise. For example, if the Effects section
for library function \tcode{F} is described as calling library function \tcode{G},
the function
\tcode{::std::G}
is meant.
\rSec3[headers]{Headers}
\pnum
Each element of the \Cpp standard library is declared or defined (as appropriate) in a
\term{header}.\footnote{ A header is not necessarily a source file, nor are the
sequences delimited by \tcode{<} and \tcode{>} in header names necessarily valid source
file names~(\ref{cpp.include}). }
\pnum
The \Cpp standard library provides
53
\term{\Cpp library headers},
\indextext{header!C++ library}%
as shown in Table~\ref{tab:cpp.library.headers}.
\begin{floattable}{\Cpp library headers}{tab:cpp.library.headers}
{lllll}
\topline
\tcode{<algorithm>} &
\tcode{<fstream>} &
\tcode{<list>} &
\tcode{<regex>} &
\tcode{<tuple>} \\
\tcode{<array>} &
\tcode{<functional>} &
\tcode{<locale>} &
\tcode{<scoped_allocator>} &
\tcode{<type_traits>} \\
\tcode{<atomic>} &
\tcode{<future>} &
\tcode{<map>} &
\tcode{<set>} &
\tcode{<typeindex>} \\
\tcode{<bitset>} &
\tcode{<initializer_list>} &
\tcode{<memory>} &
\tcode{<sstream>} &
\tcode{<typeinfo>} \\
\tcode{<chrono>} &
\tcode{<iomanip>} &
\tcode{<mutex>} &
\tcode{<stack>} &
\tcode{<unordered_map>} \\
\tcode{<codecvt>} &
\tcode{<ios>} &
\tcode{<new>} &
\tcode{<stdexcept>} &
\tcode{<unordered_set>} \\
\tcode{<complex>} &
\tcode{<iosfwd>} &