[support.types] (original) (raw)

17 Language support library [support]

17.2 Common definitions [support.types]

17.2.1 Header synopsis [cstddef.syn]

namespace std { using ptrdiff_t = see below;using size_t = see below;using max_align_t = see below;using nullptr_t = decltype(nullptr);enum class byte : unsigned char {};template<class IntType> constexpr byte& operator<<=(byte& b, IntType shift) noexcept;template<class IntType> constexpr byte operator<<(byte b, IntType shift) noexcept;template<class IntType> constexpr byte& operator>>=(byte& b, IntType shift) noexcept;template<class IntType> constexpr byte operator>>(byte b, IntType shift) noexcept;constexpr byte& operator|=(byte& l, byte r) noexcept;constexpr byte operator|(byte l, byte r) noexcept;constexpr byte& operator&=(byte& l, byte r) noexcept;constexpr byte operator&(byte l, byte r) noexcept;constexpr byte& operator^=(byte& l, byte r) noexcept;constexpr byte operator^(byte l, byte r) noexcept;constexpr byte operator~(byte b) noexcept;template<class IntType> constexpr IntType to_integer(byte b) noexcept;} #define NULL see below #define offsetof(P, D) see below

The contents and meaning of the header are the same as the C standard library header , except that it does not declare the type wchar_t, that it also declares the type byteand its associated operations ([support.types.byteops]), and as noted in[support.types.nullptr] and[support.types.layout].

See also: ISO/IEC 9899:2018, 7.19

17.2.2 Header synopsis [cstdlib.syn]

[Note 1:

Several functions have additional overloads in this document, but they have the same behavior as in the C standard library.

— _end note_]

See also: ISO/IEC 9899:2018, 7.22

17.2.3 Null pointers [support.types.nullptr]

The type nullptr_t is a synonym for the type of a nullptr expression, and it has the characteristics described in [basic.fundamental] and [conv.ptr].

[Note 1:

Although nullptr's address cannot be taken, the address of anothernullptr_t object that is an lvalue can be taken.

— _end note_]

The macroNULLis an implementation-defined null pointer constant.159

See also: ISO/IEC 9899:2018, 7.19

17.2.4 Sizes, alignments, and offsets [support.types.layout]

The macrooffsetof(type, member-designator)has the same semantics as the corresponding macro in the C standard library header , but accepts a restricted set of _type_arguments in this document.

Use of the offsetof macro with a _type_other than a standard-layout class ([class.prop]) is conditionally-supported.160

The expression offsetof(type, member-designator)is never type-dependent and it isvalue-dependent if and only if type is dependent.

The result of applying the offsetof macro to a static data member or a function member is undefined.

No operation invoked by the offsetof macro shall throw an exception andnoexcept(offsetof(type, member-designator)) shall be true.

The type ptrdiff_t is animplementation-defined signed integer type that can hold the difference of two subscripts in an array object, as described in [expr.add].

The type size_t is animplementation-defined unsigned integer type that is large enough to contain the size in bytes of any object ([expr.sizeof]).

Recommended practice: An implementation should choose types for ptrdiff_t and size_twhose integer conversion ranks ([conv.rank]) are no greater than that ofsigned long int unless a larger size is necessary to contain all the possible values.

The typemax_align_t is a trivially copyable standard-layout type whose alignment requirement is at least as great as that of every scalar type, and whose alignment requirement is supported in every context ([basic.align]).

std​::​is_trivially_default_constructible_v<max_align_t> is true.

See also: ISO/IEC 9899:2018, 7.19

17.2.5 byte type operations [support.types.byteops]

template<class IntType> constexpr byte& operator<<=(byte& b, IntType shift) noexcept;

Constraints: is_integral_v<IntType> is true.

Effects: Equivalent to:return b = b << shift;

template<class IntType> constexpr byte operator<<(byte b, IntType shift) noexcept;

Constraints: is_integral_v<IntType> is true.

Effects: Equivalent to:return static_cast<byte>(static_cast<unsigned int>(b) << shift);

template<class IntType> constexpr byte& operator>>=(byte& b, IntType shift) noexcept;

Constraints: is_integral_v<IntType> is true.

Effects: Equivalent to:return b = b >> shift;

template<class IntType> constexpr byte operator>>(byte b, IntType shift) noexcept;

Constraints: is_integral_v<IntType> is true.

Effects: Equivalent to:return static_cast<byte>(static_cast<unsigned int>(b) >> shift);

constexpr byte& operator|=(byte& l, byte r) noexcept;

Effects: Equivalent to: return l = l | r;

constexpr byte operator|(byte l, byte r) noexcept;

Effects: Equivalent to:return static_cast<byte>(static_cast<unsigned int>(l) | static_cast<unsigned int>(r));

constexpr byte& operator&=(byte& l, byte r) noexcept;

Effects: Equivalent to: return l = l & r;

constexpr byte operator&(byte l, byte r) noexcept;

Effects: Equivalent to:return static_cast<byte>(static_cast<unsigned int>(l) & static_cast<unsigned int>(r));

constexpr byte& operator^=(byte& l, byte r) noexcept;

Effects: Equivalent to: return l = l ^ r;

constexpr byte operator^(byte l, byte r) noexcept;

Effects: Equivalent to:return static_cast<byte>(static_cast<unsigned int>(l) ^ static_cast<unsigned int>(r));

constexpr byte operator~(byte b) noexcept;

Effects: Equivalent to:return static_cast<byte>(~static_cast<unsigned int>(b));

template<class IntType> constexpr IntType to_integer(byte b) noexcept;

Constraints: is_integral_v<IntType> is true.

Effects: Equivalent to: return static_cast<IntType>(b);