std::is_arithmetic — cppreference.com
De cppreference.com
<metanoindex/>
<tbody> </tbody>
| Déclaré dans l'en-tête <type_traits> |
||
|
|
(depuis C++11) | |
If T is an arithmetic type (that is, an integral type or a floating-point type), provides the member constant value equal true. For any other type, value is false.
Inherited from std::integral_constant
Member constants
value [ statique Original: static The text has been machine-translated via Google Translate. |
Original:
The text has been machine-translated via Google Translate. (constante membre statique publique) |
Member functions
convertit l'objet en Original: converts the object to The text has been machine-translated via Google Translate. (fonction membre publique) | |
Member types
Type d' Original: Type The text has been machine-translated via Google Translate. |
Definition |
value_type
|
bool
|
type
|
std::integral_constant<bool, value>
|
Notes
Arithmetic types are the types for which the built-in opérateurs arithmétiques (+, -, *, /) are defined (possibly in combination with the usual arithmetic conversions)
Specializations of std::numeric_limits are provided for all arithmetic types.
Mise en œuvre possible
template< class T > struct is_arithmetic : std::integral_constant<bool, std::is_integral<T>::value || std::is_floating_point<T>::value> {};
Exemple
#include <iostream> #include <type_traits> class A {}; int main() { std::cout << std::boolalpha; std::cout << std::is_arithmetic<A>::value << '\n'; std::cout << std::is_arithmetic<int>::value << '\n'; std::cout << std::is_arithmetic<int&>::value << '\n'; std::cout << std::is_arithmetic<int*>::value << '\n'; std::cout << std::is_arithmetic<float>::value << '\n'; std::cout << std::is_arithmetic<float&>::value << '\n'; std::cout << std::is_arithmetic<float*>::value << '\n'; }
Résultat :
false true false false true false false
Voir aussi
vérifie si un type est de type intégral Original: checks if a type is integral type The text has been machine-translated via Google Translate. (classe générique) [edit] | |
vérifie si un type est type à virgule flottante Original: checks if a type is floating-point type The text has been machine-translated via Google Translate. (classe générique) [edit] | |