is_arithmetic Class

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at is_arithmetic Class.

Tests if type is arithmetic.

template <class Ty>  
struct is_arithmetic;  

Parameters

Ty
The type to query.

An instance of the type predicate holds true if the type Ty is an arithmetic type, that is, an integral type or a floating point type, or a cv-qualified form of one of them, otherwise it holds false.

// std_tr1__type_traits__is_arithmetic.cpp   
// compile with: /EHsc   
#include <type_traits>   
#include <iostream>   
  
struct trivial   
    {   
    int val;   
    };   
  
int main()   
    {   
    std::cout << "is_arithmetic<trivial> == " << std::boolalpha   
        << std::is_arithmetic<trivial>::value << std::endl;   
    std::cout << "is_arithmetic<int> == " << std::boolalpha   
        << std::is_arithmetic<int>::value << std::endl;   
    std::cout << "is_arithmetic<float> == " << std::boolalpha   
        << std::is_arithmetic<float>::value << std::endl;   
  
    return (0);   
    }  
  

is_arithmetic<trivial> == false  
is_arithmetic<int> == true  
is_arithmetic<float> == true  

Header: <type_traits>

Namespace: std

<type_traits>
is_floating_point Class
is_integral Class

Show: