Type traits | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Compile-time rational arithmetic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Compile-time integer sequences | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(C++14) |
Defined in header <type_traits> | ||
template<class T> struct decay; | (since C++11) | |
Performs the type conversions equivalent to the ones performed when passingfunction arguments by value. Formally:
T
is “array ofU
” or reference to it, the member typedeftype
isU*
.T
is a function typeF
or reference to one, the member typedeftype
isstd::add_pointer<F>::type.type
isstd::remove_cv<std::remove_reference<T>::type>::type.If the program adds specializations forstd::decay
, the behavior is undefined.
Contents |
Name | Definition |
type | the result of applying the decay type conversions toT |
template<class T> using decay_t=typename decay<T>::type; | (since C++14) | |
template<class T>struct decay{private:typedeftypenamestd::remove_reference<T>::type U;public:typedeftypenamestd::conditional<std::is_array<U>::value,typenamestd::add_pointer<typenamestd::remove_extent<U>::type>::type,typenamestd::conditional<std::is_function<U>::value,typenamestd::add_pointer<U>::type,typenamestd::remove_cv<U>::type>::type>::type type;}; |
#include <type_traits> template<typename T,typename U>constexprbool is_decay_equ=std::is_same_v<std::decay_t<T>, U>; static_assert( is_decay_equ<int,int>&&! is_decay_equ<int,float>&& is_decay_equ<int&,int>&& is_decay_equ<int&&,int>&& is_decay_equ<constint&,int>&& is_decay_equ<int[2],int*>&&! is_decay_equ<int[4][2],int*>&&! is_decay_equ<int[4][2],int**>&& is_decay_equ<int[4][2],int(*)[2]>&& is_decay_equ<int(int),int(*)(int)>); int main(){}
(C++20) | combinesstd::remove_cv andstd::remove_reference (class template)[edit] |
implicit conversion | array-to-pointer, function-to-pointer, lvalue-to-rvalue conversions |