Difference between revisions of "cpp/types"
From cppreference.com
< cpp
m (restore anchor on type traits) |
m (→See also: added link to type traits.) |
||
(11 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
− | {{title|Type support (basic types, RTTI | + | {{title|Type support (basic types, RTTI)}} |
{{cpp/types/navbar}} | {{cpp/types/navbar}} | ||
− | + | See also [[cpp/language/type|type system overview]] and [[cpp/language/types|fundamental types defined by the language]]. | |
− | + | ||
− | + | ||
− | + | ||
===Additional basic types and macros=== | ===Additional basic types and macros=== | ||
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc header | cstddef | + | {{dsc header|cstddef}} |
− | + | {{dsc inc|cpp/types/dsc size_t}} | |
− | {{dsc inc | cpp/types/dsc size_t}} | + | {{dsc inc|cpp/types/dsc ptrdiff_t}} |
− | {{dsc inc | cpp/types/dsc ptrdiff_t}} | + | {{dsc inc|cpp/types/dsc nullptr_t}} |
− | {{dsc inc | cpp/types/dsc nullptr_t}} | + | {{dsc inc|cpp/types/dsc NULL}} |
− | {{dsc inc | cpp/types/dsc NULL}} | + | {{dsc inc|cpp/types/dsc max_align_t}} |
− | {{dsc inc | cpp/types/dsc max_align_t}} | + | {{dsc inc|cpp/types/dsc offsetof}} |
− | {{dsc inc | cpp/types/dsc offsetof | + | {{dsc inc|cpp/types/dsc byte}} |
− | + | ||
− | {{dsc inc | cpp/types/dsc byte}} | + | |
{{dsc break}} | {{dsc break}} | ||
{{dsc sep}} | {{dsc sep}} | ||
− | {{dsc header | cstdbool | {{mark deprecated}} {{mark until c++20}} }} | + | {{dsc header|cstdbool|{{mark deprecated}} {{mark until c++20}}}} |
− | {{dsc header | stdbool.h}} | + | {{dsc header|stdbool.h}} |
− | {{dsc inc | cpp/types/dsc bool_true_false_are_defined}} | + | {{dsc inc|cpp/types/dsc bool_true_false_are_defined}} |
{{dsc sep}} | {{dsc sep}} | ||
− | {{dsc header | cstdalign| {{mark deprecated}} {{mark until c++20}} }} | + | {{dsc header|cstdalign|{{mark deprecated}} {{mark until c++20}}}} |
− | {{dsc header | stdalign.h}} | + | {{dsc header|stdalign.h}} |
− | {{dsc inc | cpp/types/dsc alignas_is_defined}} | + | {{dsc inc|cpp/types/dsc alignas_is_defined}} |
+ | {{dsc inc|cpp/types/dsc alignof_is_defined}} | ||
{{dsc end}} | {{dsc end}} | ||
− | ===[[cpp/types/integer | Fixed width integer types]] {{mark since c++11}}=== | + | ===[[cpp/types/integer|Fixed width integer types]] {{mark since c++11}}=== |
− | == | + | ===[[cpp/types/floating-point|Fixed width floating-point types]] {{mark since c++23}}=== |
+ | ===Numeric limits=== | ||
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc header | limits}} | + | {{dsc header|limits}} |
− | {{dsc inc | cpp/types/dsc numeric_limits}} | + | {{dsc inc|cpp/types/dsc numeric_limits}} |
{{dsc end}} | {{dsc end}} | ||
− | ===[[cpp/types/climits|C numeric limits interface]]== | + | ====[[cpp/types/climits|C numeric limits interface]]==== |
− | + | ||
− | + | ||
+ | ===Runtime type identification=== | ||
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc header | typeinfo}} | + | {{dsc header|typeinfo}} |
− | {{dsc inc | cpp/types/dsc type_info}} | + | {{dsc inc|cpp/types/dsc type_info}} |
− | {{dsc inc | cpp/types/dsc bad_typeid}} | + | {{dsc inc|cpp/types/dsc bad_typeid}} |
− | {{dsc inc | cpp/types/dsc bad_cast}} | + | {{dsc inc|cpp/types/dsc bad_cast}} |
{{dsc sep}} | {{dsc sep}} | ||
− | {{dsc header | typeindex}} | + | {{dsc header|typeindex}} |
− | {{dsc inc | cpp/types/dsc type_index}} | + | {{dsc inc|cpp/types/dsc type_index}} |
{{dsc end}} | {{dsc end}} | ||
− | == | + | ===Defect reports=== |
− | + | {{dr list begin}} | |
− | + | {{dr list item|wg=lwg|dr=4036|std=C++11|before={{tt|__alignof_is_defined}} was underspecified in the C++ standard|after=specified and deprecated}} | |
− | + | {{dr list end}} | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | = | + | |
− | + | ||
− | {{ | + | |
− | {{ | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | = | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | = | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | = | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | = | + | |
− | + | ||
− | {{ | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | {{ | + | |
− | ==See also== | + | ===See also=== |
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc see c | c/types | Type support library | nomono=true}} | + | {{dsc|[[cpp/meta#Type traits|Type traits and metaprogramming library]]}} |
+ | {{dsc see c|c/types|Type support library|nomono=true}} | ||
{{dsc end}} | {{dsc end}} | ||
{{langlinks|de|es|fr|it|ja|pt|ru|zh}} | {{langlinks|de|es|fr|it|ja|pt|ru|zh}} |
Latest revision as of 07:49, 9 April 2024
See also type system overview and fundamental types defined by the language.
Contents |
[edit] Additional basic types and macros
Defined in header
<cstddef> | |
unsigned integer type returned by the sizeof operator (typedef) | |
signed integer type returned when subtracting two pointers (typedef) | |
(C++11) |
the type of the null pointer literal nullptr (typedef) |
implementation-defined null pointer constant (macro constant) | |
(C++11) |
trivial type with alignment requirement as great as any other scalar type (typedef) |
byte offset from the beginning of a standard-layout type to specified member (function macro) | |
(C++17) |
the byte type (enum) |
Defined in header
<stdbool.h> | |
__bool_true_false_are_defined (C++11)(deprecated) |
C compatibility macro constant, expands to integer literal 1 (macro constant) |
Defined in header
<stdalign.h> | |
__alignas_is_defined (C++11)(deprecated) |
C compatibility macro constant, expands to integer literal 1 (macro constant) |
__alignof_is_defined (C++11)(deprecated) |
C compatibility macro constant, expands to integer literal 1 (macro constant) |
[edit] Fixed width integer types (since C++11)
[edit] Fixed width floating-point types (since C++23)
[edit] Numeric limits
Defined in header
<limits> | |
provides an interface to query properties of all fundamental numeric types (class template) |
[edit] C numeric limits interface
[edit] Runtime type identification
Defined in header
<typeinfo> | |
contains some type’s information, the class returned by the typeid operator (class) | |
exception that is thrown if an argument in a typeid expression is null (class) | |
exception that is thrown by an invalid dynamic_cast expression, i.e. a cast of reference type fails (class) | |
Defined in header
<typeindex> | |
(C++11) |
wrapper around a type_info object, that can be used as index in associative and unordered associative containers (class) |
[edit] Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 4036 | C++11 | __alignof_is_defined was underspecified in the C++ standard
|
specified and deprecated |
[edit] See also
Type traits and metaprogramming library | |
C documentation for Type support library
|