◐ Shell
clean mode source ↗

std::is_arithmetic — cppreference.com

De cppreference.com

<metanoindex/>

<tbody> </tbody>

Déclaré dans l'en-tête

<type_traits>

template< class T > struct is_arithmetic;

(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.
You can help to correct and verify the translation. Click here for instructions.

]

true si T is an arithmetic type , false autrement

Original:

true if T is an arithmetic type , false otherwise

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(constante membre statique publique)

Member functions

convertit l'objet en bool, retourne value

Original:

converts the object to bool, returns value

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(fonction membre publique)

Member types

Type d'

Original:

Type

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

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.
You can help to correct and verify the translation. Click here for instructions.


(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.
You can help to correct and verify the translation. Click here for instructions.


(classe générique) [edit]