%!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, nonzero values such that, for any pair \term{Ci}
and \term{Cj} where \term{i} != \term{j}, \term{Ci} \& \term{Ci} is nonzero and
\term{Ci} \& \term{Cj} is zero.
\indextext{bitmask!empty}%
Additionally, the value 0 is used to represent an \term{empty bitmask}, in which no
bitmask elements are set.

\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>} &
\tcode{<numeric>} &
\tcode{<streambuf>} &
\tcode{<utility>} \\

\tcode{<condition_variable>} &
\tcode{<iostream>} &
\tcode{<ostream>} &
\tcode{<string>} &
\tcode{<valarray>} \\

\tcode{<deque>} &
\tcode{<istream>} &
\tcode{<queue>} &
\tcode{<strstream>} &
\tcode{<vector>} \\

\tcode{<exception>} &
\tcode{<iterator>} &
\tcode{<random>} &
\tcode{<system_error>} & \\

\tcode{<forward_list>} &
\tcode{<limits>} &
\tcode{<ratio>} &
\tcode{<thread>} & \\

\end{floattable}


\pnum
The facilities of the C standard Library are provided in 26
\indextext{library!C standard}%
additional headers, as shown in Table~\ref{tab:cpp.c.headers}.

\begin{floattable}{\Cpp headers for C library facilities}{tab:cpp.c.headers}
{lllll}
\topline

\tcode{<cassert>}           &
\tcode{<cinttypes>}         &
\tcode{<csignal>}           &
\tcode{<cstdio>}            &
\tcode{<cwchar>}            \\

\tcode{<ccomplex>}          &
\tcode{<ciso646>}           &
\tcode{<cstdalign>}         &
\tcode{<cstdlib>}           &
\tcode{<cwctype>}           \\

\tcode{<cctype>}            &
\tcode{<climits>}           &
\tcode{<cstdarg>}           &
\tcode{<cstring>}           & \\

\tcode{<cerrno>}            &
\tcode{<clocale>}           &
\tcode{<cstdbool>}          &
\tcode{<ctgmath>}           & \\

\tcode{<cfenv>}             &
\tcode{<cmath>}             &
\tcode{<cstddef>}           &
\tcode{<ctime>}             & \\

\tcode{<cfloat>}            &
\tcode{<csetjmp>}           &
\tcode{<cstdint>}           &
\tcode{<cuchar>}            & \\


\end{floattable}

\pnum
Except as noted in Clauses~\ref{\firstlibchapter} through~\ref{\lastlibchapter}
and Annex~\ref{depr}, the contents of each header \tcode{c\textit{name}} shall
be the same as that of the corresponding header \tcode{\textit{name}.h}, as
specified in the C standard library~(\ref{intro.refs}) or the C Unicode TR, as
appropriate, as if by inclusion. In the \Cpp standard library, however, the
declarations (except for names which are defined as macros in C) are within
namespace scope~(\ref{basic.scope.namespace}) of the namespace \tcode{std.} It
is unspecified whether these names are first declared within the global
namespace scope and are then injected into namespace \tcode{std} by explicit
\grammarterm{using-declaration}{s}~(\ref{namespace.udecl}).

\pnum
Names which are defined as macros in C shall be defined as macros in the \Cpp
standard library, even if C grants license for implementation as functions.
\enternote The names defined as macros in C include the following:
\tcode{assert}, \tcode{offsetof}, \tcode{setjmp}, \tcode{va_arg},
\tcode{va_end}, and \tcode{va_start}. \exitnote

\pnum
Names that are defined as functions in C shall be defined as functions in the
\Cpp standard library.\footnote{ This disallows the practice, allowed in C, of
providing a masking macro in addition to the function prototype. The only way to
achieve equivalent inline behavior in \Cpp is to provide a definition as an
extern inline function.}

\pnum
Identifiers that are keywords or operators in \Cpp shall not be defined as
macros in \Cpp standard library headers.\footnote{In particular, including the
standard header \tcode{<iso646.h>} or \tcode{<ciso646>} has no effect.}

\pnum
\ref{depr.c.headers}, C standard library headers, describes the effects of using
the \tcode{\textit{name}.h} (C header) form in a \Cpp program.\footnote{ The
\tcode{".h"} headers dump all their names into the global namespace, whereas the
newer forms keep their names in namespace \tcode{std}. Therefore, the newer
forms are the preferred forms for all uses except for \Cpp programs which are
intended to be strictly compatible with C. }

\rSec3[compliance]{Freestanding implementations}

\pnum
Two kinds of implementations are defined:
\term{hosted}
and
\term{freestanding}~(\ref{intro.compliance}).
For a hosted implementation, this International Standard
\indextext{implementation!hosted}%
describes the set of available headers.

\pnum
A freestanding implementation\indextext{implementation!freestanding} has an
\impldef{headers for freestanding implementation} set of headers. This set shall
include at least the headers shown in Table~\ref{tab:cpp.headers.freestanding}.

\begin{libsumtab}{\Cpp headers for freestanding implementations}{tab:cpp.headers.freestanding}
                    &                            &   \tcode{<ciso646>}       \\ \rowsep
\ref{support.types} & Types                       &   \tcode{<cstddef>}       \\ \rowsep
\ref{support.limits}& Implementation properties  &  \tcode{<cfloat>} \tcode{<limits>} \tcode{<climits>}        \\ \rowsep
\ref{cstdint}       & Integer types               &  \tcode{<cstdint>}        \\ \rowsep
\ref{support.start.term}& Start and termination  &   \tcode{<cstdlib>}       \\ \rowsep
\ref{support.dynamic} & Dynamic memory management &   \tcode{<new>}           \\ \rowsep
\ref{support.rtti}  & Type identification          &   \tcode{<typeinfo>}      \\ \rowsep
\ref{support.exception} & Exception handling      &   \tcode{<exception>}     \\ \rowsep
\ref{support.initlist}  & Initializer lists & \tcode{<initializer_list>} \\ \rowsep
\ref{support.runtime} & Other runtime support     &   \tcode{<cstdalign>} \tcode{<cstdarg>} \tcode{<cstdbool>}       \\ \rowsep
\ref{meta} & Type traits     &   \tcode{<type_traits>}  \\ \rowsep
\ref{atomics} & Atomics       &   \tcode{<atomic>}     \\
\end{libsumtab}

\pnum
The supplied version of the header
\tcode{<cstdlib>}
\indextext{\idxhdr{cstdlib}}%
\indexlibrary{\idxhdr{cstdlib}}%
shall declare at least the functions
\tcode{abort},
\tcode{atexit},
\tcode{at_quick_exit},
\tcode{exit},
and \tcode{quick_exit}
\indexlibrary{\idxcode{abort}}%
\indexlibrary{\idxcode{atexit}}%
\indexlibrary{\idxcode{exit}}%
(\ref{support.start.term}).
The other headers listed in this table shall meet the same requirements as for a hosted implementation.

\rSec2[using]{Using the library}

\rSec3[using.overview]{Overview}

\pnum
This section describes how a \Cpp program gains access to the facilities of the
\Cpp standard library. \ref{using.headers} describes effects during translation
phase 4, while~\ref{using.linkage} describes effects during phase
8~(\ref{lex.phases}).

\rSec3[using.headers]{Headers}

\pnum
The entities in the \Cpp standard library are defined in headers,
whose contents are made available to a translation unit when it contains the appropriate
\indextext{unit!translation}%
\tcode{\#include}
preprocessing directive~(\ref{cpp.include}).%
\indextext{\idxcode{\#include}}%
\indextext{source file}

\pnum
A translation unit may include library headers in any order (Clause~\ref{lex}).
\indextext{unit!translation}%
Each may be included more than once, with no effect different from
being included exactly once, except that the effect of including either
\tcode{<cassert>}
or
\tcode{<assert.h>}
depends each time on the lexically
\indextext{\idxhdr{cassert}}%
\indexlibrary{\idxhdr{cassert}}%
\indextext{\idxhdr{assert.h}}%
\indexlibrary{\idxhdr{assert.h}}%
current definition of
\indextext{\idxcode{NDEBUG}}%
\indexlibrary{\idxcode{NDEBUG}}%
\tcode{NDEBUG}.\footnote{This is the same as the Standard C library.}

\pnum
A translation unit shall include a header only outside of any
\indextext{unit!translation}%
external declaration or definition, and shall include the header lexically
before the first reference in that translation unit to any of the entities
declared in that header. No diagnostic is required.

\rSec3[using.linkage]{Linkage}

\pnum
Entities in the \Cpp standard library have external linkage~(\ref{basic.link}).
Unless otherwise specified, objects and functions have the default
\tcode{extern "C++"}
linkage~(\ref{dcl.link}).

\pnum
\indextext{library!C standard}%
Whether a name from the C standard library declared with
external linkage has
\indextext{linkage!external}%
\indextext{header!C library}%
\indextext{\idxcode{extern ""C""}}%
\tcode{extern "C"}
or
\indextext{\idxcode{extern ""C++""}}%
\tcode{extern "C++"}
linkage is \impldef{linkage of names from Standard C library}. It is recommended that an
implementation use
\tcode{extern "C++"}
linkage for this purpose.\footnote{The only reliable way to declare an object or
function signature from the Standard C library is by including the header that
declares it, notwithstanding the latitude granted in 7.1.4 of the C
Standard.}

\pnum
Objects and functions
defined in the library and required by a \Cpp program are included in
the program prior to program startup.

\indextext{startup!program}%
\xref
replacement functions~(\ref{replacement.functions}),
run-time changes~(\ref{handler.functions}).

\rSec2[utility.requirements]{Requirements on types and expressions}

\pnum
\ref{utility.arg.requirements}
describes requirements on types and expressions used to instantiate templates
defined in the \Cpp standard library.
\ref{swappable.requirements} describes the requirements on swappable types and
swappable expressions.
\ref{nullablepointer.requirements} describes the requirements on pointer-like
types that support null values.
\ref{hash.requirements} describes the requirements on hash function objects.
\ref{allocator.requirements} describes the requirements on storage
allocators.

\rSec3[utility.arg.requirements]{Template argument requirements}

\pnum
The template definitions in the \Cpp standard library
refer to various named requirements whose details are set out in
tables~\ref{equalitycomparable}--\ref{destructible}.
In these tables, \tcode{T} is an object or reference type to be
supplied by a \Cpp program instantiating a template;
\tcode{a},
\tcode{b}, and
\tcode{c} are values of type (possibly \tcode{const}) \tcode{T};
\tcode{s} and \tcode{t} are modifiable lvalues of type \tcode{T};
\tcode{u} denotes an identifier;
\tcode{rv} is an rvalue of type \tcode{T};
and \tcode{v} is an lvalue of type (possibly \tcode{const}) \tcode{T} or an rvalue of
type \tcode{const T}.

\pnum
In general, a default constructor is not required. Certain container class
member function signatures specify \tcode{T()} as a default argument.
\tcode{T()} shall be a well-defined expression~(\ref{dcl.init}) if one of those
signatures is called using the default argument~(\ref{dcl.fct.default}).

\indextext{requirements!\idxcode{EqualityComparable}}%
\begin{concepttable}{\tcode{EqualityComparable} requirements}{equalitycomparable}
{x{1in}x{1in}p{3in}}
\topline
Expression  &   Return type &   \multicolumn{1}{c|}{Requirement} \\ \capsep
\tcode{a == b}  &
convertible to \tcode{bool} &
\tcode{==} is an equivalence relation,
that is, it has the following properties:
\begin{itemize}
\item
For all \tcode{a}, \tcode{a == a}.
\item
If \tcode{a == b}, then \tcode{b == a}.
\item
If \tcode{a == b} and \tcode{b == c}, then \tcode{a == c}.
\end{itemize} \\
\end{concepttable}

\indextext{requirements!\idxcode{LessThanComparable}}%
\begin{concepttable}{\tcode{LessThanComparable} requirements}{lessthancomparable}
{x{1in}x{1in}p{3in}}
\topline
Expression  &   Return type &   Requirement \\ \capsep
\tcode{a < b}   &
convertible to \tcode{bool} &
\tcode{<} is a strict weak ordering relation~(\ref{alg.sorting})    \\
\end{concepttable}

\enlargethispage{-3\baselineskip}
\indextext{requirements!\idxcode{DefaultConstructible}}%
\begin{concepttable}{\tcode{DefaultConstructible} requirements}{defaultconstructible}
{x{2.15in}p{3in}}
\topline
Expression        &     Post-condition  \\ \capsep
\tcode{T t;}      &     object \tcode{t} is default-initialized   \\ \rowsep
\tcode{T u\{\};}    &     object \tcode{u} is value-initialized     \\ \rowsep
\tcode{T()}       &     a temporary object of type \tcode{T} is value-initialized \\
\tcode{T\{\}}       &     \\
\end{concepttable}

\indextext{requirements!\idxcode{MoveConstructible}}%
\begin{concepttable}{\tcode{MoveConstructible} requirements}{moveconstructible}
{p{1in}p{4.15in}}
\topline
Expression          &   Post-condition  \\ \capsep
\tcode{T u = rv;}    &   \tcode{u} is equivalent to the value of \tcode{rv} before the construction\\ \rowsep
\tcode{T(rv)}       &
  \tcode{T(rv)} is equivalent to the value of \tcode{rv} before the construction \\ \rowsep
\multicolumn{2}{|p{5.3in}|}{
  \tcode{rv}'s state is unspecified
  \enternote \tcode{rv} must still meet the requirements of the library
  component that is using it. The operations listed in those requirements must
  work as specified whether \tcode{rv} has been moved from or not. \exitnote}\\
\end{concepttable}

\indextext{requirements!\idxcode{CopyConstructible}}%
\begin{concepttable}{\tcode{CopyConstructible} requirements (in addition to \tcode{MoveConstructible})}{copyconstructible}
{p{1in}p{4.15in}}
\topline
Expression          &   Post-condition  \\ \capsep
\tcode{T u = v;}     &   the value of \tcode{v} is unchanged and is equivalent to \tcode{ u}\\ \rowsep
\tcode{T(v)}        &
  the value of \tcode{v} is unchanged and is equivalent to \tcode{T(v)} \\
\end{concepttable}

\indextext{requirements!\idxcode{MoveAssignable}}%
\begin{concepttable}{\tcode{MoveAssignable} requirements}{moveassignable}
{p{1in}p{1in}p{1in}p{1.9in}}
\topline
Expression      &   Return type &   Return value    &   Post-condition  \\ \capsep
\tcode{t = rv}  &   \tcode{T\&} &   \tcode{t}       &   \tcode{t} is equivalent
  to the value of \tcode{rv} before the assignment\\ \rowsep
\multicolumn{4}{|p{5.3in}|}{
  \tcode{rv}'s state is unspecified.
  \enternote\ \tcode{rv} must still meet the requirements of the library
  component that is using it. The operations listed in those requirements must
  work as specified whether \tcode{rv} has been moved from or not. \exitnote}\\
\end{concepttable}

\indextext{requirements!\idxcode{CopyAssignable}}%
\begin{concepttable}{\tcode{CopyAssignable} requirements (in addition to \tcode{MoveAssignable})}{copyassignable}
{p{1in}p{1in}p{1in}p{1.9in}}
\topline
Expression  &   Return type &   Return value    &   Post-condition  \\ \capsep
\tcode{t = v}   &   \tcode{T\&} &   \tcode{t}   &   \tcode{t} is equivalent to \tcode{v}, the value of \tcode{v} is unchanged\\
\end{concepttable}

\indextext{requirements!\idxcode{Destructible}}
\begin{concepttable}{\tcode{Destructible} requirements}{destructible}
{p{1in}p{4.15in}}
\topline
Expression      &   Post-condition  \\ \capsep
\tcode{u.$\sim$T()} &   All resources owned by \tcode{u} are reclaimed, no exception is propagated. \\
\end{concepttable}

\rSec3[swappable.requirements]{\tcode{Swappable} requirements}

\pnum
This subclause provides definitions for swappable types and expressions. In these
definitions, let \tcode{t} denote an expression of type \tcode{T}, and let \tcode{u}
denote an expression of type \tcode{U}.

\pnum
An object \tcode{t} is \defn{swappable with} an object \tcode{u} if and only if:

\begin{itemize}
\item the expressions \tcode{swap(t, u)} and \tcode{swap(u, t)} are valid when
evaluated in the context described below, and

\item these expressions have the following effects:

\begin{itemize}
\item the object referred to by \tcode{t} has the value originally held by \tcode{u} and
\item the object referred to by \tcode{u} has the value originally held by \tcode{t}.
\end{itemize}
\end{itemize}

\pnum
The context in which \tcode{swap(t, u)} and \tcode{swap(u, t)} are evaluated shall
ensure that a binary non-member function named ``swap'' is selected via overload
resolution~(\ref{over.match}) on a candidate set that includes:

\begin{itemize}
\item the two \tcode{swap} function templates defined in
\tcode{<utility>}~(\ref{utility}) and

\item the lookup set produced by argument-dependent lookup~(\ref{basic.lookup.argdep}).
\end{itemize}

\enternote If \tcode{T} and \tcode{U} are both fundamental types or arrays of
fundamental types and the declarations from the header \tcode{<utility>} are in
scope, the overall lookup set described above is equivalent to that of the
qualified name lookup applied to the expression \tcode{std::swap(t, u)} or
\tcode{std::swap(u, t)} as appropriate. \exitnote

\enternote It is unspecified whether a library component that has a swappable
requirement includes the header \tcode{<utility>} to ensure an appropriate
evaluation context. \exitnote

\pnum
An rvalue or lvalue \tcode{t} is \defn{swappable} if and only if \tcode{t} is
swappable with any rvalue or lvalue, respectively, of type \tcode{T}.

\pnum
A type \tcode{X} satisfying any of the iterator requirements~(\ref{iterator.requirements})
satisfies the requirements of \tcode{ValueSwappable} if,
for any dereferenceable object
\tcode{x} of type \tcode{X},
\tcode{*x} is swappable.

\enterexample User code can ensure that the evaluation of \tcode{swap} calls
is performed in an appropriate context under the various conditions as follows:
\begin{codeblock}
#include <utility>

// Requires: \tcode{std::forward<T>(t)} shall be swappable with \tcode{std::forward<U>(u)}.
template <class T, class U>
void value_swap(T&& t, U&& u) {
  using std::swap;
  swap(std::forward<T>(t), std::forward<U>(u)); // OK: uses ``swappable with'' conditions
                                                // for rvalues and lvalues
}

// Requires: lvalues of \tcode{T} shall be swappable.
template <class T>
void lv_swap(T& t1 T& t2) {
  using std::swap;
  swap(t1, t2);                                 // OK: uses swappable conditions for
}                                               // lvalues of type \tcode{T}

namespace N {
  struct A { int m; };
  struct Proxy { A* a; };
  Proxy proxy(A& a) { return Proxy{ &a }; }

  void swap(A& x, Proxy p) {
    std::swap(x.m, p.a->m);                     // OK: uses context equivalent to swappable
                                                // conditions for fundamental types
  }
  void swap(Proxy p, A& x) { swap(x, p); }      // satisfy symmetry constraint
}

int main() {
  int i = 1, j = 2;
  lv_swap(i, j);
  assert(i == 2 && j == 1);

  N::A a1 = { 5 }, a2 = { -5 };
  value_swap(a1, proxy(a2));
  assert(a1.m == -5 && a2.m == 5);
}
\end{codeblock}
\exitexample

\rSec3[nullablepointer.requirements]{\tcode{NullablePointer} requirements}

\pnum
A \tcode{NullablePointer} type is a pointer-like type that supports null values.
A type \tcode{P} meets the requirements of \tcode{NullablePointer} if:

\begin{itemize}
\item \tcode{P} satisfies the requirements of \tcode{EqualityComparable},
\tcode{DefaultConstructible}, \tcode{CopyConstructible}, \tcode{CopyAssignable},
and \tcode{Destructible},

\item lvalues of type \tcode{P} are swappable~(\ref{swappable.requirements}),

\item the expressions shown in Table~\ref{nullablepointer} are
valid and have the indicated semantics, and

\item \tcode{P} satisfies all the other requirements of this subclause.
\end{itemize}

\pnum
A value-initialized object of type \tcode{P} produces the null value of the type.
The null value shall be equivalent only to itself. A default-initialized object
of type \tcode{P} may have an indeterminate value. \enternote Operations involving
indeterminate values may cause undefined behavior. \exitnote

\pnum
An object \tcode{p} of type \tcode{P} can be contextually converted to
\tcode{bool} (Clause~\ref{conv}). The effect shall be as if \tcode{p != nullptr}
had been evaluated in place of \tcode{p}.

\pnum
No operation which is part of the \tcode{NullablePointer} requirements shall exit
via an exception.

\pnum
In Table~\ref{nullablepointer}, \tcode{u} denotes an identifier, \tcode{t}
denotes a non-\tcode{const} lvalue of type \tcode{P}, \tcode{a} and \tcode{b}
denote values of type (possibly \tcode{const}) \tcode{P}, and \tcode{np} denotes
a value of type (possibly \tcode{const}) \tcode{std::nullptr_t}.

\indextext{requirements!\idxcode{NullablePointer}}%
\begin{concepttable}{\tcode{NullablePointer} requirements}{nullablepointer}
{lll}
\topline
Expression  &   Return type   &   Operational semantics \\ \capsep
\tcode{P u(np);}\br           &
                              &
  post: \tcode{u == nullptr}  \\
\tcode{P u = np;}             &
                              &
                              \\ \rowsep

\tcode{P(np)}                 &
                              &
  post: \tcode{P(np) == nullptr}  \\ \rowsep

\tcode{t = np}                &
  \tcode{P\&}                 &
  post: \tcode{t == nullptr}  \\ \rowsep

\tcode{a != b}                &
  contextually convertible to \tcode{bool}  &
  \tcode{!(a == b)}           \\ \rowsep

\tcode{a == np}               &
  contextually convertible to \tcode{bool}  &
  \tcode{a == P()}            \\
\tcode{np == a}               &
                              &
                              \\ \rowsep
\tcode{a != np}               &
  contextually convertible to \tcode{bool}  &
  \tcode{!(a == np)}          \\
\tcode{np != a}               &
                              &
                              \\ \rowsep
\end{concepttable}

\rSec3[hash.requirements]{Hash requirements}

\indextext{requirements!\idxcode{Hash}}
\pnum
A type \tcode{H} meets the \tcode{Hash} requirements if:

\begin{itemize}
\item it is a function object type~(\ref{function.objects}),
\item it satisfies the requirements of \tcode{CopyConstructible} and
  \tcode{Destructible}~(\ref{utility.arg.requirements}), and
\item the expressions shown in Table~\ref{hash}
are valid and have the indicated semantics.
\end{itemize}

\pnum
Given \tcode{Key} is an argument type for function objects of type \tcode{H}, in
Table~\ref{hash} \tcode{h} is a value of type (possibly \tcode{const}) \tcode{H},
\tcode{u} is an lvalue of type \tcode{Key}, and \tcode{k} is a value of a type convertible to
(possibly \tcode{const}) \tcode{Key}.

\begin{concepttable}{\tcode{Hash} requirements}{hash}
{llp{.55\hsize}}
\topline
Expression        &     Return type     &       Requirement \\ \capsep
\tcode{h(k)}      &
  \tcode{size_t}  &
  The value returned shall depend only on the argument \tcode{k} for the duration of
  the program. \enternote Thus all evaluations of the expression \tcode{h(k)} with the
  same value for \tcode{k} yield the same result for a given execution of the program.
  \exitnote \enternote For two different
  values \tcode{t1} and \tcode{t2}, the probability that \tcode{h(t1)} and \tcode{h(t2)}
  compare equal should be very small, approaching \tcode{1.0 / numeric_limits<size_t>::max()}.
  \exitnote \\ \rowsep
\tcode{h(u)}      &
  \tcode{size_t}  &
  Shall not modify \tcode{u}. \\
\end{concepttable}

\rSec3[allocator.requirements]{Allocator requirements}

\indextext{requirements!\idxcode{Allocator}}%
\pnum
The library describes a standard set of requirements for \techterm{allocators},
which are class-type objects that encapsulate the information about an allocation model.
This information includes the knowledge of pointer types, the type of their
difference, the type of the size of objects in this allocation model, as well
as the memory allocation and deallocation primitives for it. All of the
string types (Clause~\ref{strings}),
containers (Clause~\ref{containers}) (except array),
string buffers and string streams (Clause~\ref{input.output}), and
\tcode{match_results} (Clause~\ref{re}) are parameterized in terms of
allocators.

\pnum
The template struct \tcode{allocator_traits}~(\ref{allocator.traits}) supplies
a uniform interface to all allocator types.
Table~\ref{tab:desc.var.def} describes the types manipulated
through allocators. Table~\ref{tab:utilities.allocator.requirements}
describes the requirements on allocator types
and thus on types used to instantiate \tcode{allocator_traits}. A requirement
is optional if the last column of
Table~\ref{tab:utilities.allocator.requirements} specifies a default for a
given expression. Within the standard library \tcode{allocator_traits}
template, an optional requirement that is not supplied by an allocator is
replaced by the specified default expression. A user specialization of
\tcode{allocator_traits} may provide different defaults and may provide
defaults for different requirements than the primary template. Within
Tables~\ref{tab:desc.var.def} and~\ref{tab:utilities.allocator.requirements},
the use of \tcode{move} and \tcode{forward} always refers to \tcode{std::move}
and \tcode{std::forward}, respectively.

\begin{libreqtab2}
{Descriptive variable definitions}
{tab:desc.var.def}
\\ \topline
\lhdr{Variable} &   \rhdr{Definition}   \\  \capsep
\endfirsthead
\continuedcaption\\
\hline
\lhdr{Variable} &   \rhdr{Definition}   \\  \capsep
\endhead
\tcode{T, U, C}    &   any non-const object type~(\ref{basic.types})       \\ \rowsep
\tcode{V}       &   a type convertible to \tcode{T}         \\ \rowsep
\tcode{X}       &   an Allocator class for type \tcode{T}   \\ \rowsep
\tcode{Y}       &   the corresponding Allocator class for type \tcode{U}    \\ \rowsep
\tcode{XX}      &   the type \tcode{allocator_traits<X>}    \\ \rowsep
\tcode{YY}      &   the type \tcode{allocator_traits<Y>}    \\ \rowsep
\tcode{t}       &   a value of type \tcode{const T\&}   \\ \rowsep
\tcode{a, a1, a2}   &   values of type \tcode{X\&}      \\ \rowsep
\tcode{a3}      &   an rvalue of type \tcode{X}      \\ \rowsep
\tcode{b}       &   a value of type \tcode{Y}           \\ \rowsep
\tcode{c}       &   a pointer of type \tcode{C*} through which indirection is valid \\ \rowsep
\tcode{p}       &   a value of type \tcode{XX::pointer}, obtained
by calling \tcode{a1.allocate}, where \tcode{a1 == a}   \\ \rowsep
\tcode{q}       &   a value of type \tcode{XX::const_pointer}
obtained by conversion from a value \tcode{p}.          \\ \rowsep
\tcode{w}       &   a value of type \tcode{XX::void_pointer} obtained by
  conversion from a value \tcode{p}  \\ \rowsep
\tcode{z}       &   a value of type \tcode{XX::const_void_pointer} obtained by
  conversion from a value \tcode{q} or a value \tcode{w}  \\ \rowsep
\tcode{r}       &   a value of type \tcode{T\&}
obtained by the expression \tcode{*p}.                  \\ \rowsep
\tcode{s}       &   a value of type \tcode{const T\&}
obtained by the expression \tcode{*q} or by conversion from
a value \tcode{r}.                                      \\ \rowsep
\tcode{u}       &   a value of type \tcode{XX:const_void_pointer} obtained by
conversion from a result value of \tcode{YY::allocate}, or else a value of
type (possibly \tcode{const}) \tcode{std::nullptr_t}. \\ \rowsep
\tcode{v}       &   a value of type \tcode{V}               \\ \rowsep
\tcode{n}       &   a value of type \tcode{XX::size_type}.   \\ \rowsep
\tcode{Args}    &   a template parameter pack               \\ \rowsep
\tcode{args}    &   a function parameter pack with the pattern \tcode{Args\&\&} \\
\end{libreqtab2}

\begin{libreqtab4d}
{Allocator requirements}
{tab:utilities.allocator.requirements}
\\ \topline
\lhdr{Expression}   &   \chdr{Return type}  &   \chdr{Assertion/note} & \rhdr{Default}       \\
                    &                       &   \chdr{pre-/post-condition}  &   \\ \capsep
\endfirsthead
\continuedcaption\\
\hline
\lhdr{Expression}   &   \chdr{Return type}  &   \chdr{Assertion/note} & \rhdr{Default}       \\
                    &                       &   \chdr{pre-/post-condition}  &   \\ \capsep
\endhead
\tcode{X::pointer}          &          &   & \tcode{T*} \\ \rowsep

\tcode{X::const_pointer}    &
   &
  \tcode{X::pointer} is convertible to \tcode{X::const_pointer}   &
  \tcode{pointer_traits<X::\brk{}pointer>::\brk{}rebind<const T>}             \\ \rowsep

\tcode{X::void_pointer}\br\tcode{Y::void_pointer} &
                                                  &
  \tcode{X::pointer} is convertible to \tcode{X::void_pointer}.
  \tcode{X::void_pointer} and \tcode{Y::void_pointer} are the same type.  &
  \tcode{pointer_traits<X::\brk{}pointer>::\brk{}rebind<void>} \\ \rowsep

\tcode{X::const_void_pointer}\br\tcode{Y::const_void_pointer} &
                                                  &
  \tcode{X::pointer}, \tcode{X::const_pointer}, and \tcode{X::void_pointer} are convertible to \tcode{X::const_void_pointer}.
  \tcode{X::const_void_pointer} and \tcode{Y::const_void_pointer} are the same type.  &
  \tcode{pointer_traits<X::\brk{}pointer>::\brk{}rebind<const void>} \\ \rowsep

\tcode{X::value_type}       &
  Identical to \tcode{T}    &   & \\ \rowsep

\tcode{X::size_type}        &
  unsigned integer type     &
  a type that can represent the size of the largest object in the allocation model. &
  \tcode{make_unsigned_t<X::\brk{}difference_type>} \\ \rowsep

\tcode{X::difference_type}  &
  signed integer type       &
  a type that can represent the difference between any two pointers
    in the allocation model.&
  \tcode{pointer_traits<X::\brk{}pointer>::\brk{}difference_type} \\ \rowsep

\tcode{typename X::template rebind<U>::other}   &
  \tcode{Y}                 &
  For all \tcode{U} (including \tcode{T}), \tcode{Y::template rebind<T>::other}
    is \tcode{X}.           &
  See Note A, below.        \\ \rowsep

\tcode{*p}                  &
  \tcode{T\&}               && \\ \rowsep

\tcode{*q}                  &
  \tcode{const T\&}         &
  \tcode{*q} refers to the same object as \tcode{*p}& \\ \rowsep

\tcode{p->m}                &
  type of \tcode{T::m}      &
  \textit{pre:} \tcode{(*p).m} is well-defined. equivalent to \tcode{(*p).m}  & \\ \rowsep

\tcode{q->m}                &
  type of \tcode{T::m}      &
  \textit{pre:} \tcode{(*q).m} is well-defined. equivalent to \tcode{(*q).m}  & \\ \rowsep

\tcode{static_-} \tcode{cast<X::pointer>(w)}  &
  \tcode{X::pointer}                &
  \tcode{static_cast<X::pointer>(w)} \tcode{== p} & \\ \rowsep

\tcode{static_cast<X} \tcode{::const_pointer>(z)}  &
  \tcode{X::const_pointer}                &
  \tcode{static_cast<X} \tcode{::const_pointer>(z)} \tcode{== q} & \\ \rowsep

\tcode{a.allocate(n)}   &   \tcode{X::pointer}  &
Memory is allocated for \tcode{n} objects of type \tcode{T} but objects
are not constructed. \tcode{allocate} may raise an appropriate exception.\footnotemark
\enternote
If \tcode{n == 0}, the return value is unspecified.
\exitnote              &  \\ \rowsep

\tcode{a.allocate(n, u)}    &
  \tcode{X::pointer}        &
  Same as \tcode{a.allocate(n)}. The use of \tcode{u} is unspecified, but
    it is intended as an aid to locality. &
  \tcode{a.allocate(n)}     \\ \rowsep

\tcode{a.deallocate(p,n)}   &
  (not used)                &
  All \tcode{n T} objects in the area pointed to by \tcode{p} shall be
    destroyed prior to this call. \tcode{n} shall match the value passed to
    \tcode{allocate} to obtain this memory. Does not throw exceptions.
    \enternote \tcode{p} shall not be singular.\exitnote   &  \\ \rowsep

\tcode{a.max_size()}        &
  \tcode{X::size_type}      &
  the largest value that can meaningfully be passed to \tcode{X::allocate()}  &
  \tcode{numeric_limits<size_type>::max()}  \\ \rowsep

\tcode{a1 == a2}            &
  \tcode{bool}              &
  returns \tcode{true} only if storage allocated from each can
    be deallocated via the other. \tcode{operator==} shall be reflexive, symmetric,
    and transitive, and shall not exit via an exception. &  \\ \rowsep

\tcode{a1 != a2}            &
  \tcode{bool}              &
  same as \tcode{!(a1 == a2)}     & \\ \rowsep

\tcode{a == b}              &
  \tcode{bool}              &
  same as \tcode{a ==} \tcode{Y::rebind<T>::other(b)} & \\ \rowsep

\tcode{a != b}              &
  \tcode{bool}              &
  same as \tcode{!(a == b)} & \\ \rowsep

\tcode{X a1(a)};            \br
\tcode{X a1 = a;}           &
                            &
  Shall not exit via an exception.\br
  post: \tcode{a1 == a}     & \\ \rowsep

\tcode{X a(b);}             &
                            &
  Shall not exit via an exception.\br
  post: \tcode{Y(a) == b}, \tcode{a == X(b)} &  \\ \rowsep

\tcode{X a1(move(a));}      \br
\tcode{X a1 = move(a);}     &
                            &
  Shall not exit via an exception.\br
  post: \tcode{a1} equals the prior value of \tcode{a}. & \\ \rowsep

\tcode{X a(move(b));}       &
                            &
  Shall not exit via an exception.\br
  post: \tcode{a} equals the prior value of \tcode{X(b)}. & \\ \rowsep

\tcode{a.construct(c, args)}&
  (not used)                &
  Effect: Constructs an object of type \tcode{C} at
    \tcode{c}               &
  \tcode{::new ((void*)c) C(forward<\brk{}Args>\brk(args)...)}  \\ \rowsep

\tcode{a.destroy(c)}        &
  (not used)                &
  Effect: Destroys the object at \tcode{c}  &
  \tcode{c->\~{}C()}           \\  \rowsep

\tcode{a.select_on_container_copy_construction()} &
  \tcode{X}                 &
  Typically returns either \tcode{a} or \tcode{X()} &
  \tcode{return a;}         \\ \rowsep

\tcode{X::propagate_on_container_copy_assignment} &
  Identical to or derived from \tcode{true_type} or \tcode{false_type}  &
  \tcode{true_type} only if an allocator of type \tcode{X} should be copied
    when the client container is copy-assigned.   &
  \tcode{false_type}        \\ \rowsep

\tcode{X::propagate_on_container_move_assignment} &
  Identical to or derived from \tcode{true_type} or \tcode{false_type}  &
  \tcode{true_type} only if an allocator of type \tcode{X} should be moved
    when the client container is move-assigned.   &
  \tcode{false_type}        \\ \rowsep

\tcode{X::propagate_on_-} \tcode{container_swap} &
  Identical to or derived from \tcode{true_type} or \tcode{false_type}  &
  \tcode{true_type} only if an allocator of type \tcode{X} should be swapped
    when the client container is swapped.   &
  \tcode{false_type}        \\

\end{libreqtab4d}

\footnotetext{It is intended that \tcode{a.allocate} be an efficient means
of allocating a single object of type \tcode{T}, even when \tcode{sizeof(T)}
is small. That is, there is no need for a container to maintain its own
free list.}

\pnum
Note A: The member class template \tcode{rebind} in the table above is
effectively a typedef template. \enternote In general, if
the name \tcode{Allocator} is bound to \tcode{SomeAllocator<T>}, then
\tcode{Allocator::rebind<U>::other} is the same type as
\tcode{SomeAllocator<U>}, where
\tcode{SomeAllocator<T>::value_type} is \tcode{T} and
\tcode{SomeAllocator<U>::\brk{}value_type} is \tcode{U}. \exitnote If
\tcode{Allocator} is a class template instantiation of the form
\tcode{SomeAllocator<T, Args>}, where \tcode{Args} is zero or more type
arguments, and \tcode{Allocator} does not supply a \tcode{rebind} member
template, the standard \tcode{allocator_traits} template uses
\tcode{SomeAllocator<U, Args>} in place of \tcode{Allocator::\brk{}rebind<U>::other}
by default. For allocator types that are not template instantiations of the
above form, no default is provided.

\pnum
An allocator type \tcode{X} shall satisfy the requirements of
\tcode{CopyConstructible}~(\ref{utility.arg.requirements}).
The \tcode{X::pointer}, \tcode{X::const_pointer}, \tcode{X::void_pointer}, and
\tcode{X::const_void_pointer} types shall satisfy the requirements of
\tcode{NullablePointer}~(\ref{nullablepointer.requirements}).
No constructor,
comparison operator, copy operation, move operation, or swap operation on
these types shall exit via an exception. \tcode{X::pointer} and \tcode{X::const_pointer} shall also
satisfy the requirements for a random access
iterator~(\ref{iterator.requirements}).

\pnum
Let \tcode{x1} and \tcode{x2} denote objects of (possibly different) types
\tcode{X::void_pointer}, \tcode{X::const_void_pointer}, \tcode{X::pointer},
or \tcode{X::const_pointer}. Then, \tcode{x1} and \tcode{x2} are
\defn{equivalently-valued} pointer values, if and only if both \tcode{x1} and \tcode{x2}
can be explicitly converted to the two corresponding objects \tcode{px1} and \tcode{px2}
of type \tcode{X::const_pointer}, using a sequence of \tcode{static_cast}s
using only these four types, and the expression \tcode{px1 == px2}
evaluates to \tcode{true}.

\pnum
Let \tcode{w1} and \tcode{w2} denote objects of type \tcode{X::void_pointer}.
Then for the expressions
\begin{codeblock}
w1 == w2
w1 != w2
\end{codeblock}
either or both objects may be replaced by an equivalently-valued object of type
\tcode{X::const_void_pointer} with no change in semantics.

\pnum
Let \tcode{p1} and \tcode{p2} denote objects of type \tcode{X::pointer}.
Then for the expressions
\begin{codeblock}
p1 == p2
p1 != p2
p1 < p2
p1 <= p2
p1 >= p2
p1 > p2
p1 - p2
\end{codeblock}
either or both objects may be replaced by an equivalently-valued object of type
\tcode{X::const_pointer} with no change in semantics.

\pnum
An allocator may constrain the types on which it can be instantiated and the
arguments for which its \tcode{construct} member may be called. If a type
cannot be used with a particular allocator, the allocator class or the call to
\tcode{construct} may fail to instantiate.

\enterexample the following is an allocator class template supporting the minimal
interface that satisfies the requirements of
Table~\ref{tab:utilities.allocator.requirements}:

\begin{codeblock}
template <class Tp>
struct SimpleAllocator {
  typedef Tp value_type;
  SimpleAllocator(@\textit{ctor args}@);

  template <class T> SimpleAllocator(const SimpleAllocator<T>& other);

  Tp* allocate(std::size_t n);
  void deallocate(Tp* p, std::size_t n);
};

template <class T, class U>
bool operator==(const SimpleAllocator<T>&, const SimpleAllocator<U>&);
template <class T, class U>
bool operator!=(const SimpleAllocator<T>&, const SimpleAllocator<U>&);
\end{codeblock}
\exitexample

\pnum
If the alignment associated with a specific over-aligned type is not
supported by an allocator, instantiation of the allocator for that type may
fail. The allocator also may silently ignore the requested alignment.
\enternote Additionally, the member function \tcode{allocate}
for that type may fail by throwing an object of type
\tcode{std::bad_alloc}.\exitnote

\rSec2[constraints]{Constraints on programs}

\rSec3[constraints.overview]{Overview}

\pnum
This section describes restrictions on \Cpp programs that use the facilities of
the \Cpp standard library. The following subclauses specify constraints on the
program's use of namespaces~(\ref{namespace.std}), its use of various reserved
names~(\ref{reserved.names}), its use of headers~(\ref{alt.headers}), its use of
standard library classes as base classes~(\ref{derived.classes}), its
definitions of replacement functions~(\ref{replacement.functions}), and its
installation of handler functions during execution~(\ref{handler.functions}).

\rSec3[namespace.constraints]{Namespace use}

\rSec4[namespace.std]{Namespace \tcode{std}}

\pnum
The behavior of a \Cpp program is undefined if it adds declarations or definitions to namespace
\tcode{std}
or to a namespace within namespace
\tcode{std}
unless otherwise specified.
A program may add a template specialization for any standard library template
to namespace
\tcode{std} only if the declaration
depends on a user-defined type
and the specialization meets the standard library requirements
for the original template and is not explicitly prohibited.\footnote{Any
library code that instantiates other library templates
must be prepared to work adequately with any user-supplied specialization
that meets the minimum requirements of the Standard.}

\pnum
The behavior of a \Cpp program is undefined if it declares
\begin{itemize}
\item an explicit specialization of any member function of a standard
library class template, or

\item an explicit specialization of any member function template of a
standard library class or class template, or

\item an explicit or partial specialization of any member class template
of a standard library class or class template.
\end{itemize}
A program may explicitly instantiate a template defined in the standard library
only if the declaration depends on the name of a user-defined type
and the instantiation meets the standard library requirements for the
original template.

\pnum
A translation unit shall not declare namespace \tcode{std} to be an inline namespace~(\ref{namespace.def}).

\rSec4[namespace.posix]{Namespace \tcode{posix}}

\pnum
The behavior of a \Cpp program is undefined if it adds declarations or definitions to namespace
\tcode{posix}
or to a namespace within namespace
\tcode{posix}
unless otherwise specified. The namespace \tcode{posix} is reserved for use by
ISO/IEC 9945 and other POSIX standards.

\rSec3[reserved.names]{Reserved names}%
\indextext{name!reserved}

\pnum
The \Cpp standard library reserves the following kinds of names:
\begin{itemize}
\item macros
\item global names
\item names with external linkage
\end{itemize}

\pnum
If a program declares or defines a name in a context where it is
reserved, other than as explicitly allowed by this Clause, its behavior is
undefined.%
\indextext{undefined}

\rSec4[macro.names]{Macro names}

\pnum
\indextext{\idxcode{\#undef}}%
\indextext{unit!translation}%
A translation unit that includes a standard library header shall not
\tcode{\#define} or \tcode{\#undef} names declared in any standard
library header.

\pnum
\indextext{unit!translation}%
A translation unit shall not \tcode{\#define} or \tcode{\#undef}
names lexically identical to keywords, to the identifiers listed in
Table~\ref{tab:identifiers.special}, or to the \grammarterm{attribute-token}{s} described
in~\ref{dcl.attr}.

\rSec4[global.names]{Global names}

\pnum
Certain sets of names and function signatures are always reserved to the implementation:

\begin{itemize}
\item
Each name that contains a double underscore
\tcode{\unun}
\indextext{character!underscore}%
or begins with an underscore followed by
an uppercase letter
\indextext{uppercase}%
(\ref{lex.key}) is reserved to the implementation for any use.
\item
Each name that begins with an underscore is
\indextext{character!underscore}%
reserved to the implementation for use as a name in the global namespace.%
\indextext{namespace!global}
\end{itemize}

\rSec4[extern.names]{External linkage}

\pnum
Each name declared as an object with external linkage
\indextext{linkage!external}%
in a header is reserved to the implementation to designate that library
object with external linkage,%
\indextext{linkage!external}\footnote{The list of such reserved names includes
\tcode{errno},
declared or defined in
\indextext{\idxhdr{cerrno}}%
\indexlibrary{\idxhdr{cerrno}}%
\tcode{<cerrno>}.}
both in namespace
\tcode{std}
and in the global namespace.

\pnum
Each
\indextext{function!global}%
global function signature declared with
\indextext{linkage!external}%
external linkage in a header is reserved to the
implementation to designate that function signature with
\indextext{linkage!external}%
external linkage.
\footnote{The list of such reserved function
signatures with external linkage includes
\indexlibrary{\idxcode{setjmp}}%
\tcode{setjmp(jmp_buf)},
declared or defined in
\indexlibrary{\idxhdr{csetjmp}}%
\tcode{<csetjmp>},
and
\indexlibrary{\idxcode{va_end}}%
\indexlibrary{\idxcode{va_list}}%
\tcode{va_end(va_list)},
declared or defined in
\indexlibrary{\idxhdr{cstdarg}}%
\tcode{<cstdarg>}.}

\pnum
Each name from the Standard C library declared with external linkage
\indextext{linkage!external}%
is reserved to the implementation for use as a name with
\indextext{header!C}%
\indextext{\idxcode{extern ""C""}}%
\tcode{extern "C"}
linkage,
both in namespace std and in the global namespace.

\pnum
Each function signature from the Standard C library declared with
\indextext{linkage!external}%
external linkage
is reserved to the implementation for use as
a function signature with both
\indextext{\idxcode{extern ""C""}}%
\tcode{extern "C"}
and
\indextext{\idxcode{extern ""C++""}}%
\tcode{extern "C++"}
linkage,
\footnote{
The function
signatures declared in
\indextext{Amendment~1}%
\indextext{\idxhdr{cuchar}}%
\indexlibrary{\idxhdr{cuchar}}%
\indextext{\idxhdr{cwchar}}%
\indexlibrary{\idxhdr{cwchar}}%
\indextext{\idxhdr{cwctype}}%
\tcode{<cuchar>}, 
\tcode{<cwchar>},
and
\tcode{<cwctype>}
are always reserved, notwithstanding the restrictions imposed in subclause
4.5.1 of Amendment 1 to the C Standard for these headers.}
or as a name of namespace scope in the global namespace.

\rSec4[extern.types]{Types}

\pnum
For each type T from the Standard C library,\footnote{These types are
\tcode{clock_t},
\tcode{div_t},
\tcode{FILE},
\tcode{fpos_t},
\tcode{lconv},
\tcode{ldiv_t},
\tcode{mbstate_t},
\tcode{ptrdiff_t},
\tcode{sig_atomic_t},
\tcode{size_t},
\tcode{time_t},
\tcode{tm},
\tcode{va_list},
\tcode{wctrans_t},
\tcode{wctype_t},
and
\tcode{wint_t}.}
the types
\tcode{::T}
and
\tcode{std::T}
are reserved to the implementation and, when defined,
\tcode{::T}
shall be identical to
\tcode{std::T}.

\rSec4[usrlit.suffix]{User-defined literal suffixes}

\pnum
Literal suffix identifiers that do not start with an underscore are reserved for future standardization.

\rSec3[alt.headers]{Headers}

\pnum
If a file with a name
\indextext{implementation-defined}%
equivalent to the derived file name for one of the \Cpp standard library headers
is not provided as part of the implementation, and a file with that name
is placed in any of the standard places for a source file to be included~(\ref{cpp.include}),
the behavior is undefined.%
\indextext{source file}%
\indextext{undefined}

\rSec3[derived.classes]{Derived classes}

\pnum
Virtual member function signatures defined
\indextext{function!virtual member}%
for a base class in the \Cpp standard
\indextext{class!base}%
\indextext{library!C++ standard}%
library may be overridden in a derived class defined in the program~(\ref{class.virtual}).

\rSec3[replacement.functions]{Replacement functions}

\pnum
\indextext{definition!alternate}%
Clauses~\ref{\firstlibchapter} through~\ref{\lastlibchapter} and Annex~\ref{depr}
describe the behavior of numerous functions defined by
the \Cpp standard library.
Under some circumstances,
\indextext{library!C++ standard}%
however, certain of these function descriptions also apply to replacement functions defined
in the program~(\ref{definitions}).

\pnum
A \Cpp program may provide the definition for any of twelve
dynamic memory allocation function signatures declared in header
\tcode{<new>}~(\ref{basic.stc.dynamic}, \ref{support.dynamic}):

\begin{itemize}
\item
\indextext{\idxcode{new}!\idxcode{operator}}%
\indexlibrary{\idxcode{new}!\idxcode{operator}}%
\tcode{operator new(std::size_t)}
\item
\tcode{operator new(std::size_t, const std::nothrow_t\&)}
\item
\indextext{\idxcode{new}!\idxcode{operator}}%
\indexlibrary{\idxcode{new}!\idxcode{operator}}%
\tcode{operator new[](std::size_t)}
\item
\tcode{operator new[](std::size_t, const std::nothrow_t\&)}
\item
\indextext{\idxcode{delete}!\idxcode{operator}}%
\indexlibrary{\idxcode{delete}!\idxcode{operator}}%
\tcode{operator delete(void*)}
\item
\tcode{operator delete(void*, const std::nothrow_t\&)}
\item
\indextext{\idxcode{delete}!\idxcode{operator}}%
\indexlibrary{\idxcode{delete}!\idxcode{operator}}%
\tcode{operator delete[](void*)}
\item
\tcode{operator delete[](void*, const std::nothrow_t\&)}
\item
\tcode{operator delete(void*, std::size_t)}
\item
\tcode{operator delete(void*, std::size_t, const std::nothrow_t\&)}
\item
\tcode{operator delete[](void*, std::size_t)}
\item
\tcode{operator delete[](void*, std::size_t, const std::nothrow_t\&)}
\end{itemize}

\pnum
The program's definitions are used instead of the default versions supplied by
the implementation~(\ref{support.dynamic}).
Such replacement occurs prior to program startup~(\ref{basic.def.odr}, \ref{basic.start}).
\indextext{startup!program}%
The program's definitions shall not be specified as
\tcode{inline}.
No diagnostic is required.

\rSec3[handler.functions]{Handler functions}

\pnum
The \Cpp standard library provides default versions of the following handler
functions (Clause~\ref{language.support}):

\begin{itemize}
\item
\tcode{unexpected_handler}
\indexlibrary{\idxcode{unexpected_handler}}%
\item
\tcode{terminate_handler}
\indexlibrary{\idxcode{terminate_handler}}%
\end{itemize}

\pnum
A \Cpp program may install different handler functions during execution, by
supplying a pointer to a function defined in the program or the library
as an argument to (respectively):

\begin{itemize}
\item
\indexlibrary{\idxcode{set_new_handler}}%
\tcode{set_new_handler}
\item
\indexlibrary{\idxcode{set_unexpected}}%
\tcode{set_unexpected}
\item
\indexlibrary{\idxcode{set_terminate}}
\tcode{set_terminate}

\xref
subclauses~\ref{alloc.errors}, Storage allocation errors, and~\ref{support.exception}, 
Exception handling.
\end{itemize}

\pnum
A \Cpp program can get a pointer to the current handler function by calling the following 
functions:

\begin{itemize}
\item
\indexlibrary{\idxcode{get_new_handler}}%
\tcode{get_new_handler}
\item
\indexlibrary{\idxcode{get_unexpected}}%
\tcode{get_unexpected}
\item
\indexlibrary{\idxcode{get_terminate}}
\tcode{get_terminate}
\end{itemize}

\pnum
Calling the \tcode{set_*} and \tcode{get_*} functions shall not incur a data race. A call to
any of the \tcode{set_*} functions shall synchronize with subsequent calls to the same
\tcode{set_*} function and to the corresponding \tcode{get_*} function.

\rSec3[res.on.functions]{Other functions}

\pnum
In certain cases (replacement functions, handler functions, operations on types used to
instantiate standard library template components), the \Cpp standard library depends on
components supplied by a \Cpp program.
If these components do not meet their requirements, the Standard places no requirements
on the implementation.

\pnum
In particular, the effects are undefined in the following cases:

\begin{itemize}
\item
for replacement functions~(\ref{new.delete}), if the installed replacement function does not
implement the semantics of the applicable
\required
paragraph.
\item
for handler functions~(\ref{new.handler}, \ref{terminate.handler}, \ref{unexpected.handler}),
if the installed handler function does not implement the semantics of the applicable
\required
paragraph
\item
for types used as template arguments when instantiating a template component,
if the operations on the type do not implement the semantics of the applicable
\synopsis{Requirements}
subclause~(\ref{allocator.requirements}, \ref{container.requirements}, \ref{iterator.requirements},
\ref{numeric.requirements}).
Operations on such types can report a failure by throwing an exception
unless otherwise specified.
\item
if any replacement function or handler function or destructor operation exits via an exception,
unless specifically allowed
in the applicable
\required
paragraph.
\item
if an incomplete type~(\ref{basic.types}) is used as a template
argument when instantiating a template component, unless specifically
allowed for that component.
\end{itemize}

\rSec3[res.on.arguments]{Function arguments}

\pnum
\indextext{restriction}%
\indextext{argument}%
Each of the following applies to all arguments
\indextext{argument}%
to functions defined in the \Cpp standard library,%
\indextext{library!C++ standard}
unless explicitly stated otherwise.

\begin{itemize}
\item
If an argument to a function has an invalid value (such
\indextext{argument}%
as a value outside the domain of the function or a pointer invalid for its
intended use), the behavior is undefined.
\indextext{undefined}%

\item
If a function argument is described as being an array,
\indextext{argument}%
the pointer actually passed to the function shall have a value such that all
address computations and accesses to objects (that would be valid if the
pointer did point to the first element of such an array) are in fact valid.

\item
If a function argument binds to an rvalue reference parameter, the implementation may
assume that this parameter is a unique reference to this argument.
\enternote
If the parameter is a generic parameter of the form \tcode{T\&\&} and an lvalue of type
\tcode{A} is bound, the argument binds to an lvalue reference~(\ref{temp.deduct.call})
and thus is not covered by the previous sentence. \exitnote \enternote If a program casts
an lvalue to an xvalue while passing that lvalue to a library function (e.g. by calling the function
with the argument \tcode{move(x)}), the program
is effectively asking that function to treat that lvalue as a temporary. The implementation
is free to optimize away aliasing checks which might be needed if the argument was
an lvalue. \exitnote
\end{itemize}

\rSec3[res.on.objects]{Shared objects and the library}

\pnum
The behavior of a program is undefined if calls to standard library functions from different
threads may introduce a data race. The conditions under which this may occur are specified
in~\ref{res.on.data.races}. \enternote Modifying an object of a standard library type that is
shared between threads risks undefined behavior unless objects of that type are explicitly
specified as being sharable without data races or the user supplies a locking mechanism. \exitnote

\pnum
\enternote In particular, the program is required to ensure that completion
of the constructor of any object of a class type defined in the standard library
happens before any other member function invocation on that object and, unless
otherwise specified, to ensure that completion of any member function invocation
other than destruction on such an object happens before destruction of that object.
This applies even to objects such as mutexes intended for thread synchronization. \exitnote

\rSec3[res.on.required]{Requires paragraph}

\pnum
\indextext{restriction}%
Violation of the preconditions specified in a function's
\requires
paragraph results in undefined behavior unless the function's
\throws
paragraph specifies throwing an exception when the precondition is violated.

\rSec2[conforming]{Conforming implementations}

\rSec3[conforming.overview]{Overview}

\pnum
This section describes the constraints upon, and latitude of, implementations of the \Cpp standard library.

\pnum
An implementation's use of headers is discussed in~\ref{res.on.headers}, its use
of macros in~\ref{res.on.macro.definitions}, global functions
in~\ref{global.functions}, member functions in~\ref{member.functions}, data race
avoidance in~\ref{res.on.data.races}, access specifiers
in~\ref{protection.within.classes}, class derivation in~\ref{derivation}, and
exceptions in~\ref{res.on.exception.handling}.

\rSec3[res.on.headers]{Headers}

\pnum
A \Cpp header may include other \Cpp headers.
A \Cpp header shall provide the declarations and definitions that appear in its
synopsis. A \Cpp header shown in its synopsis as including other \Cpp headers
shall provide the declarations and definitions that appear in the synopses of
those other headers.

\pnum
Certain types and macros are defined in more than one header.
Every such entity shall be defined such that any header that defines it may be
included after any other header that also defines it~(\ref{basic.def.odr}).

\pnum
The C standard headers (\ref{depr.c.headers})
shall include only their corresponding \Cpp standard header, as described in~\ref{headers}.

\rSec3[res.on.macro.definitions]{Restrictions on macro definitions}
\indextext{restriction}%

\pnum
The names and global function signatures described in~\ref{contents} are
\indextext{function!global}%
reserved to the implementation.
\indextext{argument}%
\indextext{header!C}%
\indextext{function!global}%
\indextext{inline}%
\indextext{macro!masking}%

\pnum
All object-like macros defined by the C standard library and described in this
Clause as expanding to integral constant expressions are also suitable for use
in \tcode{\#if}\indextext{\idxcode{\#if}} preprocessing directives, unless
explicitly stated otherwise.

\rSec3[global.functions]{Global and non-member functions}

\pnum
It is unspecified whether any global
or non-member
functions in the \Cpp standard library are defined as
\tcode{inline}~(\ref{dcl.fct.spec}).

\pnum
\indextext{function!global}A call to a global or non-member function signature
described in Clauses~\ref{\firstlibchapter} through~\ref{\lastlibchapter} and
Annex~\ref{depr} shall behave as if the implementation declared no additional
global or non-member function signatures.\footnote{A valid \Cpp program always
calls the expected library global or non-member function. An implementation may
also define additional global or non-member functions that would otherwise not
be called by a valid \Cpp program.}

\pnum
An implementation shall not declare a global or non-member function signature
with additional default arguments.

\pnum
Unless otherwise specified, global and non-member functions in the standard
library shall not use functions from another namespace which are found through
\term{argument-dependent name lookup}~(\ref{basic.lookup.argdep}).
\enternote
The phrase ``unless otherwise specified'' is intended to allow
argument-dependent lookup
in cases like that of
\tcode{ostream_iterator}s:
\effects
\begin{codeblock}
*out_stream << value;
if (delim != 0)
  *out_stream << delim;
return (*this);
\end{codeblock}
\exitnote

\rSec3[member.functions]{Member functions}

\pnum
It is unspecified whether any member functions in the \Cpp standard library are defined as
\tcode{inline}~(\ref{dcl.fct.spec}).

\pnum
An implementation may declare additional
non-virtual member function signatures within a
\indextext{function!virtual member}%
class:

\begin{itemize}
\item
by adding arguments with default values to a member function signature;%
\indextext{argument}%
\indextext{function!global}\footnote{Hence, the address of a member function of a class in the \Cpp standard
library has an unspecified type.\indextext{address~of~member~function!unspecified}}
\enternote An implementation may not add arguments with default values to virtual,
global, or non-member functions.\exitnote
\item
by replacing a member function signature with default values by two
or more member function signatures with equivalent behavior; and
\item
by adding a member function signature for a member function name.
\end{itemize}

\pnum
A call to a member function signature described in the \Cpp standard library
behaves as if the implementation declares no additional member
function signatures.\footnote{A valid \Cpp program always calls the expected library
member function, or one with equivalent behavior.
An implementation may also
define additional member functions that would otherwise not be called by a
valid \Cpp program.}

\rSec3[constexpr.functions]{\tcode{constexpr} functions and constructors}

\pnum
This standard explicitly requires that certain standard library functions are
\tcode{constexpr}~(\ref{dcl.constexpr}). An implementation shall not declare
any standard library function signature as \tcode{constexpr} except for those where
it is explicitly required.
Within any header that provides any non-defining declarations of \tcode{constexpr}
functions or constructors an implementation shall provide corresponding definitions.

\rSec3[algorithm.stable]{Requirements for stable algorithms}

\pnum
\indextext{algorithm!stable}%
\indextext{stable algorithm}%
When the requirements for an algorithm state that it is ``stable'' without further elaboration,
it means:

\begin{itemize}
\item For the \term{sort} algorithms the relative order of equivalent
elements is preserved.

\item For the \term{remove} and \term{copy} algorithms the relative order of
the elements that are not removed is preserved.

\item For the \term{merge} algorithms, for equivalent elements in
the original two ranges, the elements from the first range (preserving their
original order) precede the elements from the second range (preserving their
original order).
\end{itemize}

\rSec3[reentrancy]{Reentrancy}

\pnum
Except where explicitly specified in this standard, it is \impldef{which functions in
Standard C++ library may be recursively reentered} which functions in the Standard \Cpp
library may be recursively reentered.

\rSec3[res.on.data.races]{Data race avoidance}

\pnum
This section specifies requirements that implementations shall meet to prevent data
races~(\ref{intro.multithread}).
Every standard library function shall meet each requirement unless otherwise specified.
Implementations may prevent data races in cases other than those specified below.

\pnum
A \Cpp standard library function shall not directly or indirectly access
objects~(\ref{intro.multithread}) accessible by threads other than the current thread
unless the objects are accessed directly or indirectly via the function's arguments,
including \tcode{this}.

\pnum
A \Cpp standard library function shall not directly or indirectly modify
objects~(\ref{intro.multithread}) accessible by threads other than the current thread
unless the objects are accessed directly or indirectly via the function's non-const
arguments, including \tcode{this}.

\pnum
\enternote This means, for example, that implementations can't use a static object for
internal purposes without synchronization because it could cause a data race even in
programs that do not explicitly share objects between threads. \exitnote

\pnum
A \Cpp standard library function shall not access objects indirectly accessible via its
arguments or via elements of its container arguments except by invoking functions
required by its specification on those container elements.

\pnum
Operations on iterators obtained by calling a standard library container or string
member function may access the underlying container, but shall not modify it.
\enternote In particular, container operations that invalidate iterators conflict
with operations on iterators associated with that container. \exitnote

\pnum
Implementations may share their own internal objects between threads if the objects are
not visible to users and are protected against data races.

\pnum
Unless otherwise specified, \Cpp standard library functions shall perform all operations
solely within the current thread if those operations have effects that are
visible~(\ref{intro.multithread}) to users.

\pnum
\enternote This allows implementations to parallelize operations if there are no visible
\indextext{side effects}%
side effects. \exitnote

\rSec3[protection.within.classes]{Protection within classes}

\pnum
\indextext{protection}%
It is unspecified whether any function signature or class described in
Clauses~\ref{\firstlibchapter} through~\ref{\lastlibchapter} and Annex~\ref{depr} is a
\tcode{friend}
of another class in the \Cpp standard library.
\indextext{specifier!\tcode{friend}}

\rSec3[derivation]{Derived classes}

\pnum
\indextext{class!derived}%
\indextext{class!base}%
An implementation may derive any class in the \Cpp standard library from a class with a
name reserved to the implementation.

\pnum
Certain classes defined in the \Cpp standard library are required to be derived from
other classes
in the \Cpp standard library.
\indextext{library!C++ standard}%
An implementation may derive such a class directly from the required base or indirectly
through a hierarchy of base classes with names reserved to the implementation.

\pnum
In any case:

\begin{itemize}
\item
Every base class described as
\tcode{virtual}
shall be virtual;
\indextext{class!base}%
\item
Every base class described as
non-\tcode{virtual}
shall not be virtual;
\indextext{class!base}%
\item
Unless explicitly stated otherwise, types with distinct names shall be distinct
types.\footnote{There is an implicit exception to this rule for types that are
described as synonyms for basic integral types, such as
\tcode{size_t}~(\ref{support.types}) and
\tcode{streamoff}~(\ref{stream.types}).}
\end{itemize}

\rSec3[res.on.exception.handling]{Restrictions on exception handling}%
\indextext{restriction}%
\indextext{exception handling!handler}

\pnum
Any of the functions defined in the \Cpp standard library
\indextext{library!C++ standard}%
can report a failure by throwing an exception of a type described in its
\synopsis{Throws:}
paragraph.
An implementation may strengthen the
\grammarterm{exception-specification}
for a
non-virtual
function by adding a non-throwing \grammarterm{noexcept-specification}.

\pnum
A function may throw an object of a type not listed in its \synopsis{Throws}
clause if its type is derived from a type named in the \synopsis{Throws} clause
and would be caught by an exception handler for the base type.

\pnum
Functions from the C standard library shall not throw exceptions%
\indextext{specifications!C standard library exception}\footnote{That is, the C
library functions can all be treated as if they
are marked \tcode{noexcept}.
This allows implementations to make performance optimizations
based on the absence of exceptions at runtime.}
except when such a function calls a program-supplied function that throws an
exception.\footnote{The functions
\tcode{qsort()}
and
\tcode{bsearch()}~(\ref{alg.c.library}) meet this condition.}

\pnum
Destructor operations defined in the \Cpp standard library
shall not throw exceptions.
Every destructor in the \Cpp standard library shall behave as if it had a
non-throwing exception specification.
Any other functions defined in the
\Cpp standard library
\indextext{specifications!C++}%
that do not have an
\grammarterm{exception-specification}
may throw \impldef{exceptions thrown by standard library functions that do not have an
exception specification} exceptions
unless otherwise specified.\footnote{In particular, they
can report a failure to allocate storage by throwing an exception of type
\tcode{bad_alloc},
or a class derived from
\tcode{bad_alloc}~(\ref{bad.alloc}).
Library implementations should
report errors by throwing exceptions of or derived
from the standard exception classes~(\ref{bad.alloc},
\ref{support.exception}, \ref{std.exceptions}).}
An implementation may strengthen this implicit
\grammarterm{exception-specification}
by adding an explicit one.\footnote{That is, an implementation may provide an explicit
\grammarterm{exception-specification}
that defines the subset of ``any'' exceptions thrown by that function.
This implies that the implementation may list implementation-defined types
in such an
\indextext{types!implementation-defined exception}%
\indextext{specifications!implementation-defined exception}%
\grammarterm{exception-specification}.}

\rSec3[res.on.pointer.storage]{Restrictions on storage of pointers}

\pnum
\indextext{traceable pointer object}%
\indextext{pointer!to traceable object}%
Objects constructed by the standard library that may hold a user-supplied pointer value
or an integer of type \tcode{std::intptr_t} shall store such values in a traceable
pointer location~(\ref{basic.stc.dynamic.safety}). \enternote Other libraries are
strongly encouraged to do the same, since not doing so may result in accidental use of
pointers that are not safely derived. Libraries that store pointers outside the user's
address space should make it appear that they are stored and retrieved from a traceable
pointer location. \exitnote

\rSec3[value.error.codes]{Value of error codes}

\pnum
Certain functions in the \Cpp standard library report errors via a
\tcode{std::error_code}~(\ref{syserr.errcode.overview}) object. That object's
\tcode{category()} member shall return \tcode{std::system_category()} for
errors originating from the operating system, or a reference to an
\impldef{error_category@\tcode{error_category} for errors originating outside the
operating system} \tcode{error_category} object for errors originating elsewhere.
The implementation shall define the possible values of \tcode{value()} for each of these
error categories. \enterexample For operating systems that are based on POSIX,
implementations are encouraged to define the \tcode{std::system_category()} values as
identical to the POSIX \tcode{errno} values, with additional values as defined by the
operating system's documentation. Implementations for operating systems that are not
based on POSIX are encouraged to define values identical to the operating system's
values. For errors that do not originate from the operating system, the implementation
may provide enums for the associated values. \exitexample

\rSec3[lib.types.movedfrom]{Moved-from state of library types}

\pnum
Objects of types defined in the \Cpp standard library may be moved
from~(\ref{class.copy}). Move operations may be explicitly specified or
implicitly generated. Unless otherwise specified, such moved-from objects shall
be placed in a valid but unspecified state.
