15 Library introduction [library]

15.4 Method of description (Informative) [description]

15.4.2 Other conventions [conventions]

This subclause describes several editorial conventions used to describe the contents of the C++ standard library.
These conventions are for describing implementation-defined types, and member functions.

15.4.2.1 Type descriptions [type.descriptions]

15.4.2.1.1 General [type.descriptions.general]

The Requirements subclauses may describe names that are used to specify constraints on template arguments.160
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.
Certain types defined in [input.output] are used to describe implementation-defined types.
They are based on other types, but with added constraints.
Examples from [utility.requirements] include: Cpp17EqualityComparable, Cpp17LessThanComparable, Cpp17CopyConstructible.
Examples from [iterator.requirements] include: Cpp17InputIterator, Cpp17ForwardIterator.

15.4.2.1.2 Exposition-only types [expos.only.types]

Several types defined in [language.support] through [thread] and [depr] that are used as function parameter or return types are defined for the purpose of exposition only in order to capture their language linkage.
The declarations of such types are followed by a comment ending in exposition only.
[Example
:
namespace std {
  extern "C" using some-handler = int(int, void*, double);  // exposition only
}
The type placeholder some-handler can now be used to specify a function that takes a callback parameter with C language linkage.
end example
]

15.4.2.1.3 Enumerated types [enumerated.types]

Several types defined in [input.output] are enumerated types.
Each enumerated type may be implemented as an enumeration or as a synonym for an enumeration.161
The enumerated type enumerated can be written:
enum enumerated { V, V, V, V,  };

inline const enumerated C(V);
inline const enumerated C(V);
inline const enumerated C(V);
inline const enumerated C(V);
  ⋮
Here, the names C, C, etc.
 represent enumerated elements for this particular enumerated type.
All such elements have distinct values.
Such as an integer type, with constant integer values ([basic.fundamental]).

15.4.2.1.4 Bitmask types [bitmask.types]

Several types defined in [language.support] through [thread] and [depr] are bitmask types.
Each bitmask type can be implemented as an enumerated type that overloads certain operators, as an integer type, or as a bitset.
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.
enum bitmask : int_type {
  V = 1 << 0, V = 1 << 1, V = 1 << 2, V = 1 << 3, 
};

inline constexpr bitmask C(V);
inline constexpr bitmask C(V);
inline constexpr bitmask C(V);
inline constexpr bitmask C(V);
  ⋮

constexpr bitmask operator&(bitmask X, bitmask Y) {
  return static_cast<bitmask>(
    static_cast<int_type>(X) & static_cast<int_type>(Y));
}
constexpr bitmask operator|(bitmask X, bitmask Y) {
  return static_cast<bitmask>(
    static_cast<int_type>(X) | static_cast<int_type>(Y));
}
constexpr bitmask operator^(bitmask X, bitmask Y){
  return static_cast<bitmask>(
    static_cast<int_type>(X) ^ static_cast<int_type>(Y));
}
constexpr bitmask operator~(bitmask X){
  return static_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;
}
Here, the names C, C, etc.
 represent bitmask elements for this particular bitmask type.
All such elements have distinct, nonzero values such that, for any pair C and C where , & is nonzero and & is zero.
Additionally, the value 0 is used to represent an empty bitmask, in which no bitmask elements are set.
The following terms apply to objects and values of bitmask types:
  • To set a value Y in an object X is to evaluate the expression X |= Y.
  • To clear a value Y in an object X is to evaluate the expression X &= ~Y.
  • The value Y is set in the object X if the expression X & Y is nonzero.

15.4.2.1.5 Character sequences [character.seq]

The C standard library makes widespread use of characters and character sequences that follow a few uniform conventions:
  • A letter is any of the 26 lowercase or 26 uppercase letters in the basic execution character set.
  • The decimal-point character is the (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 [language.support] through [thread] and [depr] by a period, '.', which is also its value in the "C" locale, but may change during program execution by a call to setlocale(int, const char*),162 or by a change to a locale object, as described in [locales] and [input.output].
  • A character sequence is an array object A that can be declared as T A[N], where T is any of the types char, unsigned char, or signed char ([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.
declared in <clocale>.

15.4.2.1.5.1 Byte strings [byte.strings]

A null-terminated byte string, or ntbs, is a character sequence whose highest-addressed element with defined content has the value zero (the terminating null character); no other element in the sequence has the value zero.
163
The length of an ntbs is the number of elements that precede the terminating null character.
An empty ntbs has a length of zero.
The value of an ntbs is the sequence of values of the elements up to and including the terminating null character.
A static ntbs is an ntbs with static storage duration.164
Many of the objects manipulated by function signatures declared in <cstring> are character sequences or ntbss.
The size of some of these character sequences is limited by a length value, maintained separately from the character sequence.
A string literal, such as "abc", is a static ntbs.

15.4.2.1.5.2 Multibyte strings [multibyte.strings]

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.165
A static ntmbs is an ntmbs with static storage duration.
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.

15.4.2.1.6 Customization Point Object types [customization.point.object]

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 of a customization point object shall satisfy Semiregular ([concepts.object]).
All instances of a specific customization point object type shall be equal ([concepts.equality]).
The type T of a customization point object shall satisfy 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.
Each customization point object type constrains its return type to satisfy a particular concept.
[Note
:
Many of the customization point objects in the library evaluate function call expressions with an unqualified name which results in a call to a program-defined function found by argument dependent name lookup ([basic.lookup.argdep]).
To preclude such an expression resulting in a call to unconstrained functions with the same name in namespace std, customization point objects specify that lookup for these expressions is performed in a context that includes deleted overloads matching the signatures of overloads defined in namespace std.
When the deleted overloads are viable, program-defined overloads need be more specialized ([temp.func.order]) or more constrained ([temp.constr.order]) to be used by a customization point object.
end note
]

15.4.2.2 Functions within classes [functions.within.classes]

For the sake of exposition, [language.support] through [thread] 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.

15.4.2.3 Operators [operators]

In this library, whenever a declaration is provided for an operator!=, operator>, operator<=, or operator>= for a type T, its requirements and semantics are as follows, unless explicitly specified otherwise.
bool operator!=(const T& x, const T& y);
Requires: Type T is Cpp17EqualityComparable (Table 22).
Returns: !(x == y).
bool operator>(const T& x, const T& y);
Requires: Type T is Cpp17LessThanComparable (Table 23).
Returns: y < x.
bool operator<=(const T& x, const T& y);
Requires: Type T is Cpp17LessThanComparable (Table 23).
Returns: !(y < x).
bool operator>=(const T& x, const T& y);
Requires: Type T is Cpp17LessThanComparable (Table 23).
Returns: !(x < y).

15.4.2.4 Private members [objects.within.classes]

[language.support] through [thread] and [depr] do not specify the representation of classes, and intentionally omit specification of class members.
An implementation may define static or non-static class members, or both, as needed to implement the semantics of the member functions specified in [language.support] through [thread] 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
An implementation may use any technique that provides equivalent observable behavior.