Unless otherwise specified,
the behavior of a C++ program is undefined if it adds declarations or definitions to namespace
std
or to a namespace within namespace
std.
Unless explicitly prohibited,
a program may add a template specialization for
any standard library class template
to namespace
std provided that
(a) the added declaration
depends on at least one program-defined type
and
(b) the specialization meets the standard library requirements
for the original template.177
The behavior of a C++ program is undefined
if it declares an explicit or partial specialization
of any standard library variable template,
except where explicitly permitted by the specification of that variable template.
A program may explicitly instantiate
a class template defined in the standard library
only if the declaration
(a) depends on the name of at least one program-defined type
and
(b) the instantiation meets the standard library requirements for the
original template.
Let F denote
a standard library function ([global.functions]),
a standard library static member function,
or an instantiation
of a standard library function template.
Unless F is designated
an addressable function,
the behavior of a C++ program is unspecified (possibly ill-formed)
if it explicitly or implicitly attempts
to form a pointer
to F.
Moreover,
the behavior of a C++ program is unspecified (possibly ill-formed)
if it attempts to form a reference
to F
or
if it attempts to form a pointer-to-member designating
either a standard library non-static member function ([member.functions])
or an instantiation of a standard library member function template.
Other than in namespace std
or in a namespace
within namespace std,
a program may provide
an overload for any library function template
designated as a customization point,
provided that
(a)
the overload's declaration depends
on at least one user-defined type
and
(b)
the overload meets the standard library requirements
for the customization point.178
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 this document.
Any library customization point
must be prepared
to work adequately
with any user-defined overload
that meets the minimum requirements
of this document.
Therefore
an implementation can elect,
under the as-if rule ([intro.execution]),
to provide any customization point
in the form
of an instantiated function object ([function.objects])
even though the customization point's specification
is in the form
of a function template.
The template parameters
of each such function object
and the function parameters
and return type
of the object's operator()
must match those
of the corresponding customization point's specification.
The behavior of a C++ program is undefined if it adds declarations or definitions to namespace
posix
or to a namespace within namespace
posix
unless otherwise specified.
The namespace posix is reserved for use by
ISO/IEC 9945 and other POSIX standards.
The name stossc is reserved as a
member function for previous standardization, and may not be used as a name for
function-like macros in portable code.
A translation unit shall not #define or #undef
names lexically identical
to keywords,
to the identifiers listed in Table 4, or
to the attribute-tokens described in [dcl.attr],
except that the names likely and unlikely may be
defined as function-like macros ([cpp.replace]).
Each name declared as an object with external linkage
in a header is reserved to the implementation to designate that library
object with external linkage,179
both in namespace std and in the global namespace.
Each
global function signature declared with
external linkage in a header is reserved to the
implementation to designate that function signature with
external linkage.180
Each name from the C standard library declared with external linkage
is reserved to the implementation for use as a name with
extern"C"
linkage,
both in namespace std and in the global namespace.
Each function signature from the C standard library declared with
external linkage
is reserved to the implementation for use as
a function signature with both
extern"C"
and
extern"C++"
linkage,181
or as a name of namespace scope in the global namespace.
The list of such reserved function
signatures with external linkage includes
setjmp(jmp_buf),
declared or defined in <csetjmp>,
and
va_end(va_list),
declared or defined in
<cstdarg>.
The function signatures declared in
<cuchar>,
<cwchar>,
and
<cwctype>
are always reserved, notwithstanding the restrictions imposed in subclause
4.5.1 of Amendment 1 to the C Standard for these headers.
For each type T from the C standard library,
the types
::T
and
std::T
are reserved to the implementation and, when defined,
::T
shall be identical to
std::T.
If a file with a name
equivalent to the derived file name for one of the C++ 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,
the behavior is undefined.
Virtual member function signatures defined
for a base class in the C++ standard
library may be overridden in a derived class defined in the program ([class.virtual]).
A C++ program may provide the definition for any of the following
dynamic memory allocation function signatures declared in header
<new> ([basic.stc.dynamic], [new.syn]):
operatornew(std::size_t)operatornew(std::size_t, std::align_val_t)operatornew(std::size_t, const std::nothrow_t&)operatornew(std::size_t, std::align_val_t, const std::nothrow_t&)operatordelete(void*)operatordelete(void*, std::size_t)operatordelete(void*, std::align_val_t)operatordelete(void*, std::size_t, std::align_val_t)operatordelete(void*, const std::nothrow_t&)operatordelete(void*, std::align_val_t, const std::nothrow_t&)operatornew[](std::size_t)operatornew[](std::size_t, std::align_val_t)operatornew[](std::size_t, const std::nothrow_t&)operatornew[](std::size_t, std::align_val_t, const std::nothrow_t&)operatordelete[](void*)operatordelete[](void*, std::size_t)operatordelete[](void*, std::align_val_t)operatordelete[](void*, std::size_t, std::align_val_t)operatordelete[](void*, const std::nothrow_t&)operatordelete[](void*, std::align_val_t, const std::nothrow_t&)
A C++ 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):
In certain cases (replacement functions, handler functions, operations on types used to
instantiate standard library template components), the C++ standard library depends on
components supplied by a C++ program.
If these components do not meet their requirements, this document places no requirements
on the implementation.
For replacement functions ([new.delete]), if the installed replacement function does not
implement the semantics of the applicable
Required behavior: paragraph.
For handler functions ([new.handler], [terminate.handler]),
if the installed handler function does not implement the semantics of the applicable
Required behavior: paragraph.
If any replacement function or handler function or destructor operation exits via an exception,
unless specifically allowed
in the applicable
Required behavior: paragraph.
If an incomplete type ([basic.types]) is used as a template
argument when instantiating a template component or evaluating a concept, unless specifically
allowed for that component.
If an argument to a function has an invalid value (such
as a value outside the domain of the function or a pointer invalid for its
intended use), the behavior is undefined.
If a function argument is described as being an array,
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.
If a function argument binds to an rvalue reference parameter, the implementation may
assume that this parameter is a unique reference to this argument.
If the parameter is a generic parameter of the form T&& and an lvalue of type
A is bound, the argument binds to an lvalue reference ([temp.deduct.call])
and thus is not covered by the previous sentence.
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 std::move(x)), the program
is effectively asking that function to treat that lvalue as a temporary object.
The implementation
is free to optimize away aliasing checks which might be needed if the argument was
an lvalue.
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 shareable without data races or the user supplies a locking mechanism.
If an object of a standard library type is accessed, and
the beginning of the object's lifetime
does not happen before the access, or
the access does not happen before the end of the object's lifetime,
the behavior is undefined unless otherwise specified.
A sequence Args of template arguments is said to
model a concept C
if Args
satisfies C ([temp.constr.decl]) and
meets all semantic requirements (if any)
given in the specification of C.
If the validity or meaning of a program
depends on whether a sequence of template arguments models a concept, and
the concept is satisfied but not modeled,
the program is ill-formed, no diagnostic required.
If the semantic requirements of a declaration's
constraints ([structure.requirements]) are not modeled at the point of use,
the program is ill-formed, no diagnostic required.