%!TEX root = std.tex

\clearpage
\bigskip\noindent\textlarger{\textbf{Programming languages --- \Cpp{}}}
\bigskip\bigskip

\begingroup
\let\clearpage\relax
\rSec0[intro.scope]{Scope}
\endgroup
\copypagestyle{cpppageone}{cpppage}
\makeoddhead{cpppageone}{\textbf{WORKING DRAFT}}{}{\leaders\hrule height 2pt\hfill\kern0pt\\\textbf{\docno}}
\makeheadrule{cpppageone}{\textwidth}{2pt}
\thispagestyle{cpppageone}

\pnum
\indextext{scope|(}%
This document specifies requirements for implementations
of \Cpp{}, which is a general-purpose programming language.
The first such requirement is that
an implementation implements the language, so this document also
defines \Cpp{}. Other requirements and relaxations of the first
requirement appear at various places within this document.
\indextext{scope|)}

\rSec0[intro.refs]{Normative references}%
\indextext{normative references|see{references, normative}}%

\pnum
\indextext{references!normative|(}%
The following documents are referred to in the text
in such a way that some or all of their content
constitutes requirements
of this document. For dated references, only the edition cited applies.
For undated references, the latest edition of the referenced document
(including any amendments) applies.
\begin{itemize}
% ISO documents in numerical order.
\item ISO/IEC 2382, \doccite{Information technology --- Vocabulary}
\item ISO 8601-1:2019, \doccite{Date and time --- Representations for information interchange --- Part 1: Basic rules}
\item \IsoC{}, \doccite{Information technology --- Programming languages --- C}
\item \IsoPosix{}, \doccite{Information Technology --- Portable Operating System Interface (POSIX\textregistered)\begin{footnote}
POSIX\textregistered\ is a registered trademark of
the Institute of Electrical and Electronic Engineers, Inc.
This information is given for the convenience of users of this document and
does not constitute an endorsement by ISO or IEC of this product.
\end{footnote}
Base Specifications, Issue 7}
\item \IsoPosix{}/Cor 1:2013, \doccite{Information Technology --- Portable Operating System Interface
(POSIX\textregistered) Base Specifications, Issue 7 --- Technical Corrigendum 1}
\item \IsoPosix{}/Cor 2:2017, \doccite{Information Technology --- Portable Operating System Interface
(POSIX\textregistered) Base Specifications, Issue 7 --- Technical Corrigendum 2}
\item \IsoFloatUndated{}:2020, \doccite{Information technology --- Microprocessor Systems --- Floating-Point arithmetic}
\item ISO 80000-2:2019, \doccite{Quantities and units --- Part 2: Mathematics}
% Other international standards.
\item Ecma International, \doccite{ECMAScript
\begin{footnote}
ECMAScript\textregistered\ is a registered trademark of Ecma
International.
This information is given for the convenience of users of this document and
does not constitute an endorsement by ISO or IEC of this product.
\end{footnote}
Language Specification},
Standard Ecma-262, third edition, 1999.
\item
The Unicode Consortium. \doccite{The Unicode Standard}, Version 15.1.
Available from: \url{https://www.unicode.org/versions/Unicode15.1.0/}
\end{itemize}
\indextext{references!normative|)}

\rSec0[intro.defs]{Terms and definitions}

\pnum
\indextext{definitions|(}%
For the purposes of this document,
the terms and definitions
given in ISO/IEC 2382, ISO 80000-2:2019,
and the following apply.

\pnum
ISO and IEC maintain terminology databases
for use in standardization
at the following addresses:
\begin{itemize}
\item ISO Online browsing platform: available at \url{https://www.iso.org/obp}
\item IEC Electropedia: available at \url{https://www.electropedia.org/}
\end{itemize}

\indexdefn{access}%
\definition{access}{defns.access}
\defncontext{execution-time action}
read or modify the value of an object

\begin{defnote}
Only glvalues of scalar type\iref{basic.types.general} can be used to access objects.
Reads of scalar objects are described in \ref{conv.lval} and
modifications of scalar objects are described in
\ref{expr.assign}, \ref{expr.post.incr}, and \ref{expr.pre.incr}.
Attempts to read or modify an object of class type
typically invoke a constructor\iref{class.ctor}
or assignment operator\iref{class.copy.assign};
such invocations do not themselves constitute accesses,
although they may involve accesses of scalar subobjects.
\end{defnote}

\indexdefn{argument}%
\indexdefn{argument!function call expression}
\definition{argument}{defns.argument}
\defncontext{function call expression}
expression or \grammarterm{braced-init-list}
in the comma-separated list bounded by the parentheses

\indexdefn{argument}%
\indexdefn{argument!function-like macro}%
\definition{argument}{defns.argument.macro}
\defncontext{function-like macro} sequence of preprocessing tokens in the
comma-separated list bounded by the parentheses

\indexdefn{argument}%
\indexdefn{argument!throw expression}%
\definition{argument}{defns.argument.throw}
\defncontext{throw expression} operand of \keyword{throw}

\indexdefn{argument}%
\indexdefn{argument!template instantiation}%
\definition{argument}{defns.argument.templ}
\defncontext{template instantiation}
\grammarterm{constant-expression},
\grammarterm{type-id}, or
\grammarterm{id-expression} in the comma-separated
list bounded by the angle brackets

\indexdefn{block (execution)}%
\definition{block}{defns.block}
\defncontext{execution}
wait for some condition (other than for the implementation to execute
the execution steps of the thread of execution) to be satisfied before
continuing execution past the blocking operation

\indexdefn{block (statement)}%
\definition{block}{defns.block.stmt}
\defncontext{statement}
compound statement

\indexdefn{C!standard library}%
\definition{C standard library}{defns.c.lib}
library described in \IsoC{}, Clause 7
\begin{defnote}
With the qualifications noted in \ref{\firstlibchapter}
through \ref{\lastlibchapter} and in \ref{diff.library},
the C standard library is a subset of the \Cpp{} standard library.
\end{defnote}

\definition{character}{defns.character}
\indexdefn{character}%
\defncontext{library}
object which,
when treated sequentially,
can represent text

\begin{defnote}
The term does not mean only
\tcode{char},
\keyword{char8_t},
\keyword{char16_t},
\keyword{char32_t},
and
\keyword{wchar_t}
objects\iref{basic.fundamental},
but any value that can be represented by a type
that provides the definitions specified in
\ref{strings}, \ref{localization}, \ref{input.output}, or~\ref{re}.
\end{defnote}

\definition{character container type}{defns.character.container}
\defncontext{library}
\indexdefn{type!character container}%
class or a type used to
represent a \termref{defns.character}{character}{}

\begin{defnote}
It is used for one of the template parameters of \tcode{char_traits}
and the class templates which use that,
such as the string, iostream, and regular expression class templates.
\end{defnote}

\definition{collating element}{defns.regex.collating.element}
\indexdefn{collating element}%
sequence of one or more \termref{defns.character}{character}{s} within the
current locale that collate as if they were a single character

\definition{component}{defns.component}
\defncontext{library}
\indexdefn{component}%
group of library entities directly related as members, \termref{defns.parameter}{parameter}{s}, or
return types

\begin{defnote}
For example, the class template \tcode{basic_string}
and the non-member function templates
that operate on strings are referred to as the string component.
\end{defnote}

\indexdefn{behavior!conditionally-supported}%
\definition{conditionally-supported}{defns.cond.supp}
program construct that an implementation is not required to support

\begin{defnote}
Each implementation documents all conditionally-supported
constructs that it does not support.
\end{defnote}

\definition{constant evaluation}{defns.const.eval}
\indexdefn{constant evaluation}%
evaluation that is performed as part of evaluating an expression
as a core constant expression\iref{expr.const.core}

\definition{constant subexpression}{defns.const.subexpr}
\indexdefn{constant subexpression}%
expression whose evaluation as subexpression of a
\grammarterm{conditional-expression}
\tcode{CE} would not prevent \tcode{CE}
from being a core constant expression

\definition{deadlock}{defns.deadlock}
\defncontext{library}
\indexdefn{deadlock}%
situation wherein
one or more threads are unable to continue execution because each is
\termref{defns.block}{block}{ed} waiting for one or more of the others to satisfy some condition

\definition{default behavior}{defns.default.behavior.impl}
\indexdefn{behavior!default}%
\defncontext{library implementation}
specific behavior provided by the implementation,
within the scope of the \termref{defns.required.behavior}{required behavior}{}

\indexdefn{message!diagnostic}%
\definition{diagnostic message}{defns.diagnostic}
message belonging to an \impldef{diagnostic message} subset of the
implementation's output messages

\indexdefn{type!dynamic}%
\definition{dynamic type}{defns.dynamic.type}
\defncontext{glvalue} type of the most derived object to which the
glvalue refers

\begin{example}
If a pointer\iref{dcl.ptr} \tcode{p} whose type is ``pointer to
class \tcode{B}'' is pointing to a base class subobject
of class \tcode{B}, whose most derived object is of class \tcode{D}, derived
from \tcode{B}\iref{class.derived}, the dynamic type of the
expression \tcode{*p} is ``\tcode{D}''. References\iref{dcl.ref} are
treated similarly.
\end{example}

\indexdefn{type!dynamic}%
\definition{dynamic type}{defns.dynamic.type.prvalue}
\defncontext{prvalue} \termref{defns.static.type}{static type}{} of the prvalue expression

\indexdefn{behavior!erroneous}%
\definition{erroneous behavior}{defns.erroneous}
well-defined behavior that the implementation is recommended to diagnose
\begin{defnote}
Erroneous behavior is always the consequence of incorrect program code.
Implementations are allowed, but not required,
to diagnose it\iref{intro.compliance.general}.
Evaluation of a constant expression\iref{expr.const.core}
never exhibits behavior specified as erroneous in \ref{intro} through \ref{\lastcorechapter}.
\end{defnote}

\definition{expression-equivalent}{defns.expression.equivalent}
\defncontext{library}
\indexdefn{expression-equivalent}%
expressions that all have the same effects,
either
are all potentially-throwing or
are all not potentially-throwing,
and
either
are all \termref{defns.const.subexpr}{constant subexpression}{s} or
are all not constant subexpressions

\begin{example}
For a value \tcode{x} of type \tcode{int}
and a function \tcode{f} that accepts integer arguments,
the expressions
\tcode{f(x + 2)},
\tcode{f(2 + x)},
and
\tcode{f(1 + x + 1)}
are expression-equivalent.
\end{example}

\definition{finite state machine}{defns.regex.finite.state.machine}
\defncontext{regular expression}
\indexdefn{finite state machine}%
unspecified data structure that is used to
represent a \termref{defns.regex.regular.expression}{regular expression}{}, and which permits efficient matches
against the regular expression to be obtained

\definition{format specifier}{defns.regex.format.specifier}
\defncontext{regular expression}
\indexdefn{format specifier}%
sequence of one or more \termref{defns.character}{character}{s} that is expected to be
replaced with some part of a \termref{defns.regex.regular.expression}{regular expression}{} match

\definition{handler function}{defns.handler}
\defncontext{library}
\indexdefn{function!handler}%
non-reserved function whose definition may be provided by a \Cpp{} program

\begin{defnote}
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 (see \ref{support}).
\end{defnote}

\indexdefn{program!ill-formed}%
\definition{ill-formed program}{defns.ill.formed}
program that is not well-formed\iref{defns.well.formed}

\indexdefn{behavior!implementation-defined}%
\definition{implementation-defined behavior}{defns.impl.defined}
behavior, for a \termref{defns.well.formed}{well-formed program}{} construct and correct data, that
depends on the implementation and that each implementation documents

\definition{implementation-defined strict total order over pointers}
{defns.order.ptr}
\indexdefn{pointer!strict total order}%
\defncontext{library}
\impldef{strict total order over pointer values}
strict total ordering over all pointer values
such that the ordering is consistent with the partial order
imposed by the built-in operators
\tcode{<}, \tcode{>}, \tcode{<=}, \tcode{>=}, and \tcode{<=>}

\indexdefn{limits!implementation}%
\definition{implementation limit}{defns.impl.limits}
restriction imposed upon programs by the implementation

\indexdefn{behavior!locale-specific}%
\definition{locale-specific behavior}{defns.locale.specific}
behavior that depends on local conventions of nationality, culture, and
language that each implementation documents

\definition{matched}{defns.regex.matched}
\defncontext{regular expression}
\indexdefn{matched}%
\indexdefn{regular expression!matched}%
condition when a sequence of zero or more \termref{defns.character}{character}{s}
correspond to a sequence of characters defined by the pattern

\definition{modifier function}{defns.modifier}
\defncontext{library}
\indexdefn{function!modifier}%
class member function other than a constructor,
assignment operator, or destructor
that alters the state of an object of the class

\definition{move assignment}{defns.move.assign}
\defncontext{library}
\indexdefn{assignment!move}%
assignment of an rvalue of some object type to a modifiable lvalue of the same type

\definition{move construction}{defns.move.constr}
\defncontext{library}
\indexdefn{construction!move}%
direct-initialization of an object of some type with an rvalue of the same type

\indexdefn{library call!non-constant}%
\definition{non-constant library call}{defns.nonconst.libcall}
invocation of a library function that,
as part of evaluating any expression \tcode{E},
prevents \tcode{E} from being a core constant expression

\definition{NTCTS}{defns.ntcts}
\defncontext{library}
\indexdefn{NTCTS}%
\indexdefn{string!null-terminated character type}%
sequence of values that have
\termref{defns.character}{character}{} type
that precede the terminating null character type
value
\tcode{charT()}

\definition{observer function}{defns.observer}
\defncontext{library}
\indexdefn{function!observer}%
class member function that accesses the state of an object of the class
but does not alter that state

\begin{defnote}
Observer functions are specified as
\keyword{const}
member functions.
\end{defnote}

\indexdefn{parameter}%
\indexdefn{parameter!function}%
\indexdefn{parameter!catch clause}%
\definition{parameter}{defns.parameter}
\defncontext{function or catch clause} object or reference declared as part of a function declaration or
definition or in the catch clause of an exception handler that
acquires a value on entry to the function or handler

\indexdefn{parameter}%
\indexdefn{parameter!function-like macro}%
\definition{parameter}{defns.parameter.macro}
\defncontext{function-like macro} identifier from
the comma-separated list bounded by the parentheses immediately
following the macro name

\indexdefn{parameter}%
\indexdefn{parameter!template}%
\definition{parameter}{defns.parameter.templ}
\defncontext{template} member of a \grammarterm{template-parameter-list}

\definition{primary equivalence class}{defns.regex.primary.equivalence.class}
\defncontext{regular expression}
\indexdefn{primary equivalence class}%
set of one or more \termref{defns.character}{character}{s} which
share the same primary sort key: that is the sort key weighting that
depends only upon character shape, and not accents, case, or
locale-specific tailorings

\definition{program-defined specialization}{defns.prog.def.spec}
\defncontext{library}
\indexdefn{specialization!program-defined}%
explicit template specialization or partial specialization
that is not part of the \Cpp{} standard library and
not defined by the implementation

\definition{program-defined type}{defns.prog.def.type}
\defncontext{library}
\indexdefn{type!program-defined}%
non-closure class type or enumeration type
that is not part of the \Cpp{} standard library and
not defined by the implementation,
or a closure type of a non-implementation-provided lambda expression,
or an instantiation of a \termref{defns.prog.def.spec}{program-defined specialization}{}

\begin{defnote}
Types defined by the implementation include
extensions\iref{intro.compliance} and internal types used by the library.
\end{defnote}

\definition{projection}{defns.projection}
\indexdefn{projection}%
\defncontext{library}
transformation that an algorithm applies
before inspecting the values of elements

\begin{example}
\begin{codeblock}
std::pair<int, std::string_view> pairs[] = {{2, "foo"}, {1, "bar"}, {0, "baz"}};
std::ranges::sort(pairs, std::ranges::less{}, [](auto const& p) { return p.first; });
\end{codeblock}
sorts the pairs in increasing order of their \tcode{first} members:
\begin{codeblock}
{{0, "baz"}, {1, "bar"}, {2, "foo"}}
\end{codeblock}
\end{example}

\indexdefn{property!of the implementation}%
\definition{property of the implementation}{defns.impl.prop}
behavior, for a well-formed program\iref{defns.well.formed}
construct and correct data, that depends on the implementation

\definition{referenceable type}{defns.referenceable}
\indexdefn{type!referenceable}%
type that is either an
object type, a function type that does not have cv-qualifiers or a
\grammarterm{ref-qualifier}, or a reference type

\begin{defnote}
The term describes a type to which a reference can be created,
including reference types.
\end{defnote}

\definition{regular expression}{defns.regex.regular.expression}
pattern that selects specific strings
from a set of \termref{defns.character}{character}{} strings

\definition{replacement function}{defns.replacement}
\defncontext{library}
\indexdefn{function!replacement}%
non-reserved function
whose definition is provided by a \Cpp{} program

\begin{defnote}
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\iref{lex.phases} and resolving the
definitions of all translation units\iref{basic.link}.
\end{defnote}

\definition{required behavior}{defns.required.behavior}
\defncontext{library}
\indexdefn{behavior!required}%
description of \termref{defns.replacement}{replacement function}{}
and \termref{defns.handler}{handler function}{} semantics
applicable to both the behavior provided by the implementation and
the behavior of any such function definition in the program

\begin{defnote}
If such a function defined in a \Cpp{} program fails to meet the required
behavior when it executes, the behavior is undefined.%
\indextext{undefined}
\end{defnote}

\definition{reserved function}{defns.reserved.function}
\defncontext{library}
\indexdefn{function!reserved}%
function, specified as part of the \Cpp{} standard library, that is defined by the
implementation

\begin{defnote}
If a \Cpp{} program provides a definition for any reserved function, the results are undefined.%
\indextext{undefined}
\end{defnote}

\definition{runtime-undefined behavior}{defns.undefined.runtime}
\indexdefn{behavior!runtime-undefined}%
behavior that is undefined except when it occurs during constant evaluation

\begin{defnote}
During constant evaluation,
\begin{itemize}
\item
it is
\impldef{whether runtime-undefined behavior results in the expression being deemed non-constant}
whether runtime-undefined behavior results in the expression being deemed non-constant
(as specified in~\ref{expr.const.core}) and
\item
runtime-undefined behavior has no other effect.
\end{itemize}
\end{defnote}

\indexdefn{signature}%
\definition{signature}{defns.signature}
\defncontext{function}
name,
parameter-type-list,
and enclosing namespace

\begin{defnote}
Signatures are used as a basis for
name mangling and linking.
\end{defnote}

\indexdefn{signature}%
\definition{signature}{defns.signature.friend}
\defncontext{non-template friend function with trailing \grammarterm{requires-clause}}
name,
parameter-type-list,
enclosing class,
and
trailing \grammarterm{requires-clause}

\indexdefn{signature}%
\definition{signature}{defns.signature.templ}
\defncontext{function template}
name,
parameter-type-list,
enclosing namespace,
return type,
\termref{defns.signature.template.head}{signature}{} of the \grammarterm{template-head},
and
trailing \grammarterm{requires-clause} (if any)

\indexdefn{signature}%
\definition{signature}{defns.signature.templ.friend}
\defncontext{friend function template with constraint involving enclosing template parameters}
name,
parameter-type-list,
return type,
enclosing class,
\termref{defns.signature.template.head}{signature}{} of the \grammarterm{template-head},
and
trailing \grammarterm{requires-clause} (if any)

\indexdefn{signature}%
\definition{signature}{defns.signature.spec}
\defncontext{function template specialization} \termref{defns.signature.templ}{signature}{} of the template of which it is a specialization
and its template \termref{defns.argument.templ}{argument}{s} (whether explicitly specified or deduced)

\indexdefn{signature}%
\definition{signature}{defns.signature.member}
\defncontext{class member function}
name,
parameter-type-list,
class of which the function is a member,
\cv-qualifiers (if any),
\grammarterm{ref-qualifier} (if any),
and
trailing \grammarterm{requires-clause} (if any)

\indexdefn{signature}%
\definition{signature}{defns.signature.member.templ}
\defncontext{class member function template}
name,
parameter-type-list,
class of which the function is a member,
\cv-qualifiers (if any),
\grammarterm{ref-qualifier} (if any),
return type (if any),
\termref{defns.signature.template.head}{signature}{} of the \grammarterm{template-head},
and
trailing \grammarterm{requires-clause} (if any)

\indexdefn{signature}%
\definition{signature}{defns.signature.member.spec}
\defncontext{class member function template specialization} \termref{defns.signature.member.templ}{signature}{} of the member function template
of which it is a specialization and its template arguments (whether explicitly specified or deduced)

\indexdefn{signature}%
\definition{signature}{defns.signature.template.head}
\defncontext{\grammarterm{template-head}}
template \termref{defns.parameter.templ}{parameter}{} list,
excluding template parameter names and default \termref{defns.argument.templ}{argument}{s},
and
\grammarterm{requires-clause} (if any)

\definition{stable algorithm}{defns.stable}
\defncontext{library}
\indexdefn{algorithm!stable}%
\indexdefn{stable algorithm}%
algorithm that preserves, as appropriate to the particular algorithm, the order
of elements

\begin{defnote}
Requirements for stable algorithms are given in \ref{algorithm.stable}.
\end{defnote}

\indexdefn{type!static}%
\definition{static type}{defns.static.type}
type of an expression resulting from
analysis of the program without considering execution semantics

\begin{defnote}
The static type of an expression depends only on the form of the program in
which the expression appears, and does not change while the program is
executing.
\end{defnote}

\definition{sub-expression}{defns.regex.subexpression}
\defncontext{regular expression}
\indexdefn{sub-expression!regular expression}%
subset of a \termref{defns.regex.regular.expression}{regular expression}{} that has
been marked by parentheses

\definition{traits class}{defns.traits}
\defncontext{library}
\indexdefn{traits}%
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

\indexdefn{unblock}%
\definition{unblock}{defns.unblock}
satisfy a condition that one or more \termref{defns.block}{blocked}{} threads of execution are waiting for

\indexdefn{behavior!undefined}%
\definition{undefined behavior}{defns.undefined}
behavior for which this document
imposes no requirements

\begin{defnote}
Undefined behavior may be expected when
this document omits any explicit
definition of behavior or when a program uses an incorrect construct or invalid data.
Permissible undefined behavior ranges
from ignoring the situation completely with unpredictable results, to
behaving during translation or program execution in a documented manner
characteristic of the environment (with or without the issuance of a
\termref{defns.diagnostic}{diagnostic message}{}), to terminating a translation or execution (with the
issuance of a diagnostic message). Many incorrect program constructs do
not engender undefined behavior; they are required to be diagnosed.
Evaluation of a constant expression\iref{expr.const.core} never exhibits behavior explicitly
specified as undefined in \ref{intro} through \ref{\lastcorechapter}.
\end{defnote}

\indexdefn{behavior!unspecified}%
\definition{unspecified behavior}{defns.unspecified}
behavior, for a \termref{defns.well.formed}{well-formed program}{} construct and correct data, that
depends on the implementation

\begin{defnote}
The implementation is not required to
document which behavior occurs. The range of
possible behaviors is usually delineated by this document.
\end{defnote}

\definition{valid but unspecified state}{defns.valid}
\defncontext{library}
\indexdefn{valid but unspecified state}%
value of an object that is not specified except that the object's invariants are
met and operations on the object behave as specified for its type

\begin{example}
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}.
\end{example}

\indexdefn{program!well-formed}%
\definition{well-formed program}{defns.well.formed}
\Cpp{} program constructed according to the syntax and semantic rules
\indextext{definitions|)}

\rSec0[intro]{General principles}

\rSec1[intro.compliance]{Implementation compliance}%
\indextext{diagnostic message|see{message, diagnostic}}%
\indexdefn{conditionally-supported behavior|see{behavior, con\-ditionally-supported}}%
\indextext{dynamic type|see{type, dynamic}}%
\indextext{static type|see{type, static}}%
\indextext{ill-formed program|see{program, ill-formed}}%
\indextext{well-formed program|see{program, well-formed}}%
\indextext{implementation-defined behavior|see{behavior, im\-plementation-defined}}%
\indextext{undefined behavior|see{behavior, undefined}}%
\indextext{unspecified behavior|see{behavior, unspecified}}%
\indextext{implementation limits|see{limits, implementation}}%
\indextext{locale-specific behavior|see{behavior, locale-spe\-cific}}%
\indextext{multibyte character|see{character, multibyte}}%
\indextext{object|seealso{object model}}%
\indextext{subobject|seealso{object model}}%
\indextext{derived class!most|see{most derived class}}%
\indextext{derived object!most|see{most derived object}}%
\indextext{program execution!as-if rule|see{as-if rule}}%
\indextext{observable behavior|see{behavior, observable}}%
\indextext{precedence of operator|see{operator, precedence of}}%
\indextext{order of evaluation in expression|see{expression, order of evaluation of}}%
\indextext{multiple threads|see{threads, multiple}}%

\rSec2[intro.compliance.general]{General}

\pnum
\indextext{conformance requirements|(}%
\indextext{conformance requirements!general|(}%
The set of
\defn{diagnosable rules}
consists of all syntactic and semantic rules in this document
except for those rules containing an explicit notation that
``no diagnostic is required'' or which are described as resulting in
``undefined behavior''.

\pnum
\indextext{conformance requirements!method of description}%
Although this document states only requirements on \Cpp{}
implementations, those requirements are often easier to understand if
they are phrased as requirements on programs, parts of programs, or
execution of programs. Such requirements have the following meaning:
\begin{itemize}
\item
If a program contains no violations of the rules in
\ref{lex} through \ref{\lastlibchapter} as well as those specified in \ref{depr},
a conforming implementation shall accept and correctly execute
\begin{footnote}
``Correct execution'' can include undefined behavior
and erroneous behavior, depending on
the data being processed; see \ref{intro.defs} and~\ref{intro.execution}.
\end{footnote}
that program,
except when the implementation's limitations (see below) are exceeded.
\item
\indextext{behavior!undefined}%
If a program contains a violation of a rule for which no diagnostic is required,
this document places no requirement on implementations
with respect to that program.

\item
\indextext{message!diagnostic}%
\indextext{contract evaluation semantics!checking}%
\indextext{contract evaluation semantics!terminating}%
Otherwise, if a program contains
\begin{itemize}
\item
a violation of any diagnosable rule,
\item
a preprocessing translation unit with
a \tcode{\#warning} preprocessing directive\iref{cpp.error},
\item
an occurrence
of a construct described in this document as ``conditionally-supported'' when
the implementation does not support that construct, or
\item
a contract assertion\iref{basic.contract.eval}
evaluated with a checking semantic
in a manifestly constant-evaluated context\iref{expr.const.defns}
resulting in a contract violation,
\end{itemize}
a conforming implementation
shall issue at least one diagnostic message.
\end{itemize}
\begin{note}
During template argument deduction and substitution,
certain constructs that in other contexts require a diagnostic
are treated differently;
see~\ref{temp.deduct}.
\end{note}
Furthermore, a conforming implementation
shall not accept
\begin{itemize}
\item
a preprocessing translation unit containing
a \tcode{\#error} preprocessing directive\iref{cpp.error},
\item
a translation unit with
a \grammarterm{static_assert-declaration} that fails\iref{dcl.pre}, or
\item
a contract assertion evaluated with a terminating semantic\iref{basic.contract.eval}
in a manifestly constant-evaluated context\iref{expr.const.defns}
resulting in a contract violation.
\end{itemize}

\pnum
\indextext{conformance requirements!library|(}%
\indextext{conformance requirements!classes}%
\indextext{conformance requirements!class templates}%
For classes and class templates, the library Clauses specify partial
definitions. Private members\iref{class.access} are not
specified, but each implementation shall supply them to complete the
definitions according to the description in the library Clauses.

\pnum
For functions, function templates, objects, and values, the library
Clauses specify declarations. Implementations shall supply definitions
consistent with the descriptions in the library Clauses.

\pnum
A \Cpp{}  translation unit\iref{lex.phases}
obtains access to the names defined in the library by
including the appropriate standard library header or importing
the appropriate standard library named header unit\iref{using.headers}.

\pnum
The templates, classes, functions, and objects in the library have
external linkage\iref{basic.link}. The implementation provides
definitions for standard library entities, as necessary, while combining
translation units to form a complete \Cpp{}  program\iref{lex.phases}.%
\indextext{conformance requirements!library|)}

\pnum
An implementation is either a
\defnadj{hosted}{implementation} or a
\defnadj{freestanding}{implementation}.
A freestanding
implementation is one in which execution may take place without the benefit of
an operating system.
A hosted implementation
supports all the facilities described in this document, while
a freestanding implementation
supports the entire \Cpp{} language
described in \ref{lex} through \ref{\lastcorechapter} and
the subset of the library facilities described in \ref{compliance}.

\pnum
It is
\impldef{whether the implementation is a hardened implementation}
whether the implementation is a
\defnadj{hardened}{implementation}.
If it is a hardened implementation,
violating a hardened precondition
results in a contract violation\iref{structure.specifications}.

\pnum
\recommended
An implementation is encouraged to document its limitations in
the size or complexity of the programs it can successfully process,
if possible and where known.
\ref{implimits} lists some quantities that can be subject to limitations and
a potential minimum supported value for each quantity.

\pnum
A conforming implementation may use an implementation-defined version
of the Unicode Standard that is a later version than the one
referenced in \ref{intro.refs}.

\pnum
A conforming implementation may have extensions (including
additional library functions), provided they do not alter the
behavior of any well-formed program.
Implementations are required to diagnose programs that use such
extensions that are ill-formed according to this document.
Having done so, however, they can compile and execute such programs.

\pnum
Each implementation shall include documentation that identifies all
conditionally-supported constructs\indextext{behavior!conditionally-supported}
that it does not support and defines all locale-specific characteristics.
\begin{footnote}
This documentation also defines implementation-defined behavior;
see~\ref{intro.abstract}.
\end{footnote}
\indextext{conformance requirements!general|)}%
\indextext{conformance requirements|)}%

\rSec2[intro.abstract]{Abstract machine}

\pnum
\indextext{program execution|(}%
\indextext{program execution!abstract machine}%
The semantic descriptions in this document define a
parameterized nondeterministic abstract machine. This document
places no requirement on the structure of conforming
implementations. In particular, they need not copy or emulate the
structure of the abstract machine.
\indextext{as-if rule}%
\indextext{behavior!observable}%
Rather, conforming implementations are required to emulate (only) the observable
behavior of the abstract machine as explained below.
\begin{footnote}
This provision is
sometimes called the ``as-if'' rule, because an implementation is free to
disregard any requirement of this document as long as the result
is \emph{as if} the requirement had been obeyed, as far as can be determined
from the observable behavior of the program. For instance, an actual
implementation need not evaluate part of an expression if it can deduce that its
value is not used and that no
\indextext{side effects}%
side effects affecting the
observable behavior of the program are produced.
\end{footnote}

\pnum
\indextext{behavior!implementation-defined}%
Certain aspects and operations of the abstract machine
constitute the parameters of the abstract machine and
are described in this
document as implementation-defined behavior (for example,
\tcode{sizeof(int)})
or as properties of the implementation (for example, padding in class types).
For implementation-defined behavior,
each implementation shall include documentation describing its characteristics
and behavior in these respects.
\begin{footnote}
This documentation also includes
conditionally-supported constructs and locale-specific behavior.
See~\ref{intro.compliance.general}.
\end{footnote}
Such documentation shall define the instance of the
abstract machine that corresponds to that implementation (referred to as the
``corresponding instance'' below).

\pnum
\indextext{behavior!unspecified}%
Certain other aspects and operations of the abstract machine are
described in this document as unspecified behavior (for example,
order of evaluation of arguments in a function call\iref{expr.call}).
Where possible, this
document defines a set of allowable behaviors. These
define the nondeterministic aspects of the abstract machine. An instance
of the abstract machine can thus have more than one possible execution
for a given program and a given input.

\pnum
\indextext{behavior!undefined}%
Certain other operations are described in this document as
undefined behavior (for example, the effect of
attempting to modify a const object).

\pnum
Certain events in the execution of a program
are termed \defnadj{observable}{checkpoints}.
\begin{note}
A call to \tcode{std::observable_checkpoint}\iref{utility.undefined}
is an observable checkpoint,
as are certain parts of
the evaluation of contract assertions\iref{basic.contract}.
\end{note}

\pnum
\indextext{program!well-formed}%
\indextext{behavior!observable}%
The \defnadj{defined}{prefix} of an execution
comprises the operations $O$
for which for every undefined operation $U$
there is an observable checkpoint $C$
such that $O$ happens before $C$ and
$C$ happens before $U$.

\begin{note}
The undefined behavior that arises from a data race\iref{intro.races}
occurs on all participating threads.
\end{note}

A conforming implementation executing a well-formed program shall
produce the observable behavior
of the defined prefix
of one of the possible executions
of the corresponding instance
of the abstract machine with the
same program and the same input.
\indextext{behavior!undefined}%
If the selected execution contains an undefined operation,
the implementation executing that program with that input
may produce arbitrary additional observable behavior afterwards.
If the execution of an operation is specified as having erroneous behavior,
the implementation is permitted to issue a diagnostic and
is permitted to terminate the execution of the program.

\pnum
\recommended
An implementation should issue a diagnostic when such an operation is executed.
\begin{note}
An implementation can issue a diagnostic
if it can determine that erroneous behavior is reachable
under an implementation-specific set of assumptions about the program behavior,
which can result in false positives.
\end{note}

\pnum
\indextext{conformance requirements}%
The following specify the
\defnadj{observable}{behavior}
of the program:
\begin{itemize}
\item
Accesses through volatile glvalues are evaluated strictly according to the
rules of the abstract machine.
\item
Data is delivered to the host environment to be written into files (\xrefc{7.23.3}).

\begin{note}
Delivering such data
is followed by an observable checkpoint\iref{cstdio.syn}.
Not all host environments provide access to file contents before program termination.
\end{note}

\item
The input and output dynamics of interactive devices shall take
place in such a fashion that prompting output is actually delivered before a program waits for input. What constitutes an interactive device is
\impldef{interactive device}.
\end{itemize}

\begin{note}
More stringent correspondences between abstract and actual
semantics can be defined by each implementation.
\end{note}
\indextext{program execution|)}%

\rSec1[intro.structure]{Structure of this document}

\pnum
\indextext{standard!structure of|(}%
\indextext{standard!structure of}%
\ref{lex} through \ref{\lastcorechapter} describe the \Cpp{} programming
language. That description includes detailed syntactic specifications in
a form described in~\ref{syntax}. For convenience, \ref{gram}
repeats all such syntactic specifications.

\pnum
\ref{\firstlibchapter} through \ref{\lastlibchapter} and \ref{depr}
(the \defn{library clauses}) describe the \Cpp{} standard library.
That description includes detailed descriptions of the
entities and macros
that constitute the library, in a form described in \ref{library}.

\pnum
\ref{implimits} recommends lower bounds on the capacity of conforming
implementations.

\pnum
\ref{diff} summarizes the evolution of \Cpp{} since its first
published description, and explains in detail the differences between
\Cpp{} and C\@. Certain features of \Cpp{} exist solely for compatibility
purposes; \ref{depr} describes those features.
\indextext{standard!structure of|)}

\rSec1[syntax]{Syntax notation}

\pnum
\indextext{notation!syntax|(}%
In the syntax notation used in this document, syntactic
categories are indicated by \fakegrammarterm{italic, sans-serif} type, and literal words
and characters in \tcode{constant} \tcode{width} type. Alternatives are
listed on separate lines except in a few cases where a long set of
alternatives is marked by the phrase ``one of''. If the text of an alternative is too long to fit on a line, the text is continued on subsequent lines indented from the first one.
An optional terminal or non-terminal symbol is indicated by the subscript
``\opt{\relax}'', so
\begin{ncbnf}
\terminal{\{} \opt{expression} \terminal{\}}
\end{ncbnf}
indicates an optional expression enclosed in braces.%

\pnum
Names for syntactic categories have generally been chosen according to
the following rules:
\begin{itemize}
\item \fakegrammarterm{X-name} is a use of an identifier in a context that
determines its meaning (e.g., \grammarterm{class-name},
\grammarterm{typedef-name}).
\item \fakegrammarterm{X-id} is an identifier with no context-dependent meaning
(e.g., \grammarterm{qualified-id}).
\item \fakegrammarterm{X-seq} is one or more \fakegrammarterm{X}'s without intervening
delimiters (e.g., \grammarterm{declaration-seq} is a sequence of
\grammarterm{declaration}s).
\item \fakegrammarterm{X-list} is one or more \fakegrammarterm{X}'s separated by
intervening commas (e.g., \grammarterm{identifier-list} is a sequence of
\grammarterm{identifier}s separated by commas).
\end{itemize}%
\indextext{notation!syntax|)}
