Namespaces
Variants
Views
Actions

std::integral

From cppreference.com
< cpp‎ | concepts
Defined in header <concepts>
template < class T >
concept integral = std::is_integral_v<T>;
(since C++20)

The concept integral<T> is satisfied if and only if T is an integral type.

[edit] Example

#include <concepts>
#include <iostream>
 
void print(std::integral auto i) {
    std::cout << "Integral: " << i << '\n';
}
 
void print(auto x) {
    std::cout << "Non-integral: " << x << '\n';
}
 
int main()
{
    print( 'o' ); static_assert( std::integral<char> );
    print( 007 ); static_assert( std::integral<int> );
    print( 2e2 ); static_assert( !std::integral<float> );
    print("∫∫∫"); static_assert( !std::integral<decltype("")> );
}

Output:

Integral: o
Integral: 7
Non-integral: 200
Non-integral: ∫∫∫

[edit] See also

checks if a type is an integral type
(class template) [edit]