class template
<type_traits>
std::is_arithmetic
template <class T> struct is_arithmetic;
Is arithmetic type
- integral_constant
- is_arithmetic
Trait class that identifies whether T is an arithmetic type (either an integral or a floating point type).
It inherits from integral_constant as being either true_type or false_type, depending on whether
T is an arithmetic type:| fundamental arithmetic types | |
|---|---|
| integral types | bool |
| char | |
| char16_t | |
| char32_t | |
| wchar_t | |
| signed char | |
| short int | |
| int | |
| long int | |
| long long int | |
| unsigned char | |
| unsigned short int | |
| unsigned int | |
| unsigned long int | |
| unsigned long long int | |
| floating point types | float |
| double | |
| long double | |
All fundamental arithmetic types, along with all their aliases (like those in cstdint), are considered arithmetic types by this class, including their const and volatile qualified variants.
Enums are not considered arithmetic types in C++ (see is_enum).
This is a compound type trait defined with the same behavior as:
|
|
Template parameters
- T
- A type.
Member types
Inherited from integral_constant:| member type | definition |
|---|---|
| value_type | bool |
| type | either true_type or false_type |
Member constants
Inherited from integral_constant:| member constant | definition |
|---|---|
| value | either true or false |
Member functions
Inherited from integral_constant:- operator bool
- Returns value (public member function)
Example
|
|
Output:
is_arithmetic: char: true float: true float*: false complex<double>: false
See also
- is_integral
- Is integral (class template)
- is_floating_point
- Is floating point (class template)
- is_fundamental
- Is fundamental type (class template)
- is_signed
- Is signed type (class template)
- is_unsigned
- Is unsigned type (class template)