Requirements are stated in terms of well-defined expressions that define valid terms of
the types that meet the requirements.
For every set of well-defined expression
requirements there is either a named concept or a table that specifies an initial set of the valid expressions and
their semantics.
Any generic algorithm ([algorithms]) that uses the
well-defined expression requirements is described in terms of the valid expressions for
its template type parameters.
The library specification uses a typographical convention for naming
requirements.
Names in italic type that begin with the prefix
Cpp17 refer to sets of well-defined expression requirements typically
presented in tabular form, possibly with additional prose semantic requirements.
For example, Cpp17Destructible (Table 35) is such a named
requirement.
Names in constant width type refer to library concepts
which are presented as a concept definition ([temp]), possibly with additional
prose semantic requirements.
In some cases the semantic requirements are presented as C++ 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.125
Required operations of any concept defined in this document need not be
total functions; that is, some arguments to a required operation may
result in the required semantics failing to be met.
The required < operator of the totally_ordered
concept ([concept.totallyordered]) does not meet the
semantic requirements of that concept when operating on NaNs.
— end example]
This does not affect whether a type models the concept.
A declaration may explicitly impose requirements through its associated
constraints ([temp.constr.decl]).
When the associated constraints refer to a
concept ([temp.concept]), the semantic constraints specified for that concept
are additionally imposed on the use of the declaration.
If the diagnostic is to be emitted only after the function
has been selected by overload resolution,
an implementation can express such a condition
via a constraint-expression ([temp.constr.decl])
and also define the function as deleted.
When invoking the function in a hardened implementation,
prior to any other observable side effects of the function,
contract assertions
whose predicates are as described in the hardened precondition
are evaluated with a terminating semantic ([basic.contract.eval]).
Result: for a typename-specifier, a description of the named type;
for an expression,
a description of the type and value category of the expression;
the expression is an lvalue if the type is an lvalue reference type,
an xvalue if the type is an rvalue reference type, and
a prvalue otherwise.
Whenever the Effects element specifies that the semantics of some function
F are Equivalent to some code sequence, then the various elements are
interpreted as follows.
If F's semantics specifies any Constraints or Mandates elements,
then those requirements are logically imposed prior to the equivalent-to semantics.
Next, the semantics of the code sequence are determined by the
Constraints,
Mandates,
Constant When,
Preconditions,
Hardened preconditions,
Effects,
Synchronization,
Postconditions,
Returns,
Throws,
Complexity,
Remarks, and
Error conditions
specified for the function invocations contained in the code sequence.
The value returned from F is specified by F's Returns element,
or if F has no Returns element,
a non-void return from F is specified by the
return statements ([stmt.return]) in the code sequence.
If F's semantics contains a Throws,
Postconditions, or Complexity element,
then that supersedes any occurrences of that element in the code sequence.
For non-reserved replacement and handler functions,
[support] specifies two behaviors for the functions in question:
their required and default behavior.
The default behavior
describes a function definition provided by the implementation.
The required behavior
describes the semantics of a function definition provided by
either the implementation or a C++ program.
Where no distinction is explicitly made in the description, the
behavior described is the required behavior.
Complexity requirements specified in the library clauses are upper bounds,
and implementations that provide better complexity guarantees meet
the requirements.
The Requirements subclauses may describe names that are used to specify
constraints on template arguments.129
These names are used in library Clauses
to describe the types that
may be supplied as arguments by a C++ program when instantiating template components from
the library.
The bitmask type bitmask can be written:
/ For exposition only./ int_type is an integral type capable of representing all values of the bitmask type.enumbitmask: int_type {V0=1<<0, V1=1<<1, V2=1<<2, V3=1<<3, …};
inlineconstexprbitmask C0(V0);
inlineconstexprbitmask C1(V1);
inlineconstexprbitmask C2(V2);
inlineconstexprbitmask C3(V3);
⋮
constexprbitmaskoperator&(bitmask X, bitmask Y){returnstatic_cast<bitmask>(static_cast<int_type>(X)&static_cast<int_type>(Y));
}constexprbitmaskoperator|(bitmask X, bitmask Y){returnstatic_cast<bitmask>(static_cast<int_type>(X)|static_cast<int_type>(Y));
}constexprbitmaskoperator^(bitmask X, bitmask Y){returnstatic_cast<bitmask>(static_cast<int_type>(X)^static_cast<int_type>(Y));
}constexprbitmaskoperator~(bitmask X){returnstatic_cast<bitmask>(~static_cast<int_type>(X));
}bitmask&operator&=(bitmask& X, bitmask Y){
X = X & Y; return X;
}bitmask&operator|=(bitmask& X, bitmask Y){
X = X | Y; return X;
}bitmask&operator^=(bitmask& X, bitmask Y){
X = X ^ Y; return X;
}
Properties specified as locale-specific
may change during program execution
by a call to setlocale(int, constchar*) ([clocale.syn]), or
by a change to a locale object,
as described in [locales] and [input.output].
The
decimal-point character
is the locale-specific
(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 [support] through [exec]
and [depr] by a period,
'.',
which is
also its value in the "C"
locale.
A
character sequence
is an array objectA that
can be declared as
T A[N],
where T is any of the types
char,
unsignedchar,
or
signedchar ([basic.fundamental]), optionally qualified by any combination of
const
or
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
S that points to its first element.
A null-terminated multibyte string,
or ntmbs,
is an ntbs that constitutes a
sequence of valid multibyte characters, beginning and ending in the initial
shift state.133
A customization point object is a function object ([function.objects])
with a literal class type that interacts with program-defined types while
enforcing semantic requirements on that interaction.
The type T of a customization point object,
ignoring cv-qualifiers, shall model
invocable<T&, Args..>,
invocable<const T&, Args..>,
invocable<T, Args..>, and
invocable<const T, Args..> ([concept.invocable])
when the types in Args.. meet the requirements specified in that
customization point object's definition.
When the types of Args.. do
not meet the customization point object's requirements, T shall not have
a function call operator that participates in overload resolution.
For an algorithm function object o,
let S be the corresponding set of function templates.
Then for any sequence of arguments args …,
o(args …) is expression-equivalent to
s(args …),
where the result of name lookup for s is the overload set S.
For the sake of exposition, [support] through [exec]
and [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 ([class.copy.ctor], [class.copy.assign], [class.dtor]).
It is unspecified whether
the implementation provides explicit definitions for such member function
signatures, or for virtual destructors that can be generated by default.
An implementation may
define static or non-static class members, or both, as needed to implement the
semantics of the member functions specified in [support]
through [exec] and [depr].
For the sake of exposition,
some subclauses provide representative declarations, and semantic requirements, for
private members of classes that meet the external specifications of the classes.
The declarations for such members are
followed by a comment that ends with exposition only, as in:
streambuf* sb; / exposition only
Unless otherwise specified,
the requirements on freestanding items for a freestanding implementation
are the same as the corresponding requirements for a hosted implementation,
except that not all of the members of those items are required to be present.
Function declarations and function template declarations
followed by a comment that include freestanding-deleted are
freestanding deleted functions.
On freestanding implementations,
it is implementation-defined
whether each entity introduced by a freestanding deleted function
is a deleted function ([dcl.fct.def.delete]) or
whether the requirements are the same as
the corresponding requirements for a hosted implementation.
Deleted definitions reduce the chance of overload resolution silently changing
when migrating from a freestanding implementation to a hosted implementation.
— end note]
[Example 1: double abs(double j); / freestanding-deleted — end example]
Freestanding annotations follow some additional exposition conventions
that do not impose any additional normative requirements.
Header synopses that begin with a comment containing "all freestanding"
contain no hosted items and no freestanding deleted functions.
Header synopses that begin with a comment containing "mostly freestanding"
contain at least one hosted item or freestanding deleted function.
Classes and class templates followed by a comment
containing "partially freestanding"
contain at least one hosted item or freestanding deleted function.