18 Language support library [language.support]

18.2 Types [support.types]

Table [tab:support.hdr.cstddef] describes the header <cstddef>.

Table 30 — Header <cstddef> synopsis
Macros: NULL offsetof
Types: ptrdiff_t size_t
max_align_t nullptr_t

The contents are the same as the Standard C library header <stddef.h>, with the following changes:

The macro NULL is an implementation-defined C++ null pointer constant in this International Standard ([conv.ptr]).195

The macro offsetof(type, member-designator) accepts a restricted set of type arguments in this International Standard. If type is not a standard-layout class (Clause [class]), the results are undefined.196 The expression offsetof(type, member-designator) is never type-dependent ([temp.dep.expr]) and it is value-dependent ([temp.dep.constexpr]) if and only if type is dependent. The result of applying the offsetof macro to a field that is a static data member or a function member is undefined. No operation invoked by the offsetof macro shall throw an exception and noexcept(offsetof(type, member-designator)) shall be true.

The type ptrdiff_t is an implementation-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 an implementation-defined unsigned integer type that is large enough to contain the size in bytes of any object.

Note: It is recommended that implementations choose types for ptrdiff_t and size_t whose integer conversion ranks ([conv.rank]) are no greater than that of signed long int unless a larger size is necessary to contain all the possible values.  — end note ]

The type max_align_t is a POD type whose alignment requirement is at least as great as that of every scalar type, and whose alignment requirement is supported in every context.

nullptr_t is defined as follows:

namespace std {
  typedef decltype(nullptr) nullptr_t;

The type for which nullptr_t is a synonym has the characteristics described in [basic.fundamental] and [conv.ptr]. [ Note: Although nullptr's address cannot be taken, the address of another nullptr_t object that is an lvalue can be taken.  — end note ]

See also: Alignment ([basic.align]), Sizeof ([expr.sizeof]), Additive operators ([expr.add]), Free store ([class.free]), and ISO C 7.1.6.

Possible definitions include 0 and 0L, but not (void*)0.

Note that offsetof is required to work as specified even if unary operator& is overloaded for any of the types involved.