Type support (basic types, RTTI, type traits)

From cppreference.com
< cpp
 
 
 
Type support
Basic types
Fundamental types
Fixed width integer types (C++11)
Numeric limits
numeric_limits
C numeric limits interface
Runtime type information
Type traits
Primary type categories
is_void (C++11)
is_array (C++11)
is_pointer (C++11)
is_enum (C++11)
is_union (C++11)
is_class (C++11)
is_function (C++11)
is_object (C++11)
is_scalar (C++11)
is_compound (C++11)
is_integral (C++11)
is_floating_point (C++11)
is_fundamental (C++11)
is_arithmetic (C++11)
is_reference (C++11)
is_lvalue_reference (C++11)
is_rvalue_reference (C++11)
is_member_pointer (C++11)
is_member_object_pointer (C++11)
is_member_function_pointer (C++11)
Type properties
is_const (C++11)
is_volatile (C++11)
is_pod (C++11)
is_empty (C++11)
is_polymorphic (C++11)
is_abstract (C++11)
Supported operations
is_constructible
is_trivially_constructible
is_nothrow_constructible
(C++11)
(C++11)
(C++11)
is_default_constructible
is_trivially_default_constructible
is_nothrow_default_constructible
(C++11)
(C++11)
(C++11)
is_copy_constructible
is_trivially_copy_constructible
is_nothrow_copy_constructible
(C++11)
(C++11)
(C++11)
is_move_constructible
is_trivially_move_constructible
is_nothrow_move_constructible
(C++11)
(C++11)
(C++11)
is_assignable
is_trivially_assignable
is_nothrow_assignable
(C++11)
(C++11)
(C++11)
is_copy_assignable
is_trivially_copy_assignable
is_nothrow_copy_assignable
(C++11)
(C++11)
(C++11)
is_move_assignable
is_trivially_move_assignable
is_nothrow_move_assignable
(C++11)
(C++11)
(C++11)
is_destructible
is_trivially_destructible
is_nothrow_destructible
(C++11)
(C++11)
(C++11)
has_virtual_destructor (C++11)
Relationships and property queries
is_same (C++11)
is_base_of (C++11)
is_convertible (C++11)
alignment_of (C++11)
rank (C++11)
extent (C++11)
Type modifications
remove_cv
remove_const
remove_volatile
(C++11)
(C++11)
(C++11)
add_cv
add_const
add_volatile
(C++11)
(C++11)
(C++11)
make_signed (C++11)
make_unsigned (C++11)
Type transformations
aligned_storage (C++11)
aligned_union (C++11)
decay (C++11)
enable_if (C++11)
conditional (C++11)
common_type (C++11)
underlying_type (C++11)
result_of (C++11)
Type trait constants
integral_constant (C++11)
 

Contents

[edit] Basic types

[edit] Fundamental types defined by the language

[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)
POD 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)
Defined in header <cstdbool>
__bool_true_false_are_defined
(C++11)
C compatibility macro constant, expands to integer constant 1
(macro constant)
Defined in header <cstdalign>
__alignas_is_defined
(C++11)
C compatibility macro constant, expands to integer constant 1
(macro constant)

[edit] Fixed width integer types (since C++11)

[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

contains some type's information, generated by the implementation.
This is the class, returned by the typeid operator
(class)
(C++11)
wrapper around a type_info object, that can be used as index in associative and unordered associative containers
(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)

[edit] Type traits (since C++11)

Type traits defines an compile-time template-based interface to query or modify the properties of types.

[edit] Type properties

Defined in header <type_traits>
Primary type categories
(C++11)
checks if a type is void
(class template)
(C++11)
checks if a type is integral type
(class template)
checks if a type is floating-point type
(class template)
(C++11)
checks if a type is an array type
(class template)
(C++11)
checks if a type is an enumeration type
(class template)
(C++11)
checks if a type is an union type
(class template)
(C++11)
checks if a type is a class type (but not union type)
(class template)
(C++11)
checks if a type is a function type
(class template)
(C++11)
checks if a type is a pointer type
(class template)
checks if a type is lvalue reference
(class template)
checks if a type is rvalue reference
(class template)
checks if a type is a pointer to a non-static member object
(class template)
checks if a type is a pointer to a non-static member function
(class template)
Composite type categories
checks if a type is fundamental type
(class template)
checks if a type is arithmetic type
(class template)
(C++11)
checks if a type is scalar type
(class template)
(C++11)
checks if a type is object type
(class template)
(C++11)
checks if a type is compound type
(class template)
(C++11)
checks if a type is either lvalue reference or rvalue reference
(class template)
checks if a type is a pointer to a non-static member function or object
(class template)
Type properties
(C++11)
checks if a type is const-qualified
(class template)
(C++11)
checks if a type is volatile-qualified
(class template)
(C++11)
checks if a type is trivial
(class template)
checks if a type is trivially copyable
(class template)
checks if a type is standard-layout type
(class template)
(C++11)
checks if a type is plain-old data (POD) type
(class template)
checks if a type is literal type
(class template)
(C++11)
checks if a type is class (but not union) type and has no data
(class template)
checks if a type is polymorphic class type
(class template)
(C++11)
checks if a type is abstract class type
(class template)
(C++11)
checks if a type is signed arithmetic type
(class template)
(C++11)
checks if a type is unsigned arithmetic type
(class template)
Supported operations
checks if a type has a constructor for specific arguments
(class template)
checks if a type has a default constructor
(class template)
checks if a type has a copy constructor
(class template)
checks if a type has a move constructor
(class template)
checks if a type has a assignment operator for a specific argument
(class template)
checks if a type has a copy assignment operator
(class template)
checks if a type has a move assignment operator
(class template)
checks if a type has a non-deleted destructor
(class template)
checks if a type has a virtual destructor
(class template)
Property queries
(C++11)
obtains the type's alignment requirements
(class template)
(C++11)
obtains the number of dimensions of an array type
(class template)
(C++11)
obtains the size of an array type along a specified dimension
(class template)
Type relationships
(C++11)
checks if two types are the same
(class template)
(C++11)
checks if a type is derived from the other type
(class template)
checks if a type can be converted to the other type
(class template)

[edit] Type modifications

Type modification templates create new type definitions by applying modifications on a template parameter. The resulting type can then be accessed through type member typedef.

Defined in header <type_traits>
Const-volatility specifiers
removes const or/and volatile specifiers from the given type
(class template)
(C++11)
(C++11)
(C++11)
adds const or/and volatile specifiers to the given type
(class template)
References
removes reference from the given type
(class template)
adds lvalue or rvalue reference to the given types
(class template)
Pointers
removes pointer from the given type
(class template)
(C++11)
adds pointer to the given type
(class template)
Sign modifiers
(C++11)
makes the given integral type signed
(class template)
makes the given integral type unsigned
(class template)
Arrays
removes one extent from the given array type
(class template)
removes all extents from the given array type
(class template)

[edit] Miscellaneous transformations

Defined in header <type_traits>
defines the type suitable for use as uninitialized storage for types of given size
(class template)
defines the type suitable for use as uninitialized storage for all given types
(class template)
(C++11)
applies type transformations as when passing a function argument by value
(class template)
(C++11)
hides a function overload or template specialization based on compile-time boolean
(class template)
(C++11)
chooses one type or another based on compile-type boolean
(class template)
(C++11)
deduces the result type of a mixed-mode arithmetic expression
(class template)
obtains the underlying integer type for a given enumeration type
(class template)
(C++11)
deduces the return type of a function call expresion
(class template)

[edit] Helper classes

Defined in header <type_traits>
compile-time constant of specified type with specified value
(class template)

Two specializations of std::integral_constant for the type bool are provided:

Defined in header <type_traits>
Type Definition
true_type std::integral_constant<bool, true>
false_type std::integral_constant<bool, false>