Hello I've seen many examples like this in Cppreference.com:
std::is_class<T>
std::is_integral
And so on. I know if I run the code for example I get true
or false
. But what is the point in that? e.g knowing the object is of class type or not?
#include <iostream>
#include <type_traits>
struct A {};
class B {};
enum class C {};
int main()
{
std::cout << std::boolalpha;
std::cout << std::is_class<A>::value << '\n';
std::cout << std::is_class<B>::value << '\n';
std::cout << std::is_class<C>::value << '\n';
std::cout << std::is_class<int>::value << '\n';
}
The output:
true
true
false
false
I've searched all over for a real example using this (
is_class
,is_integral
,is_arithmetic
, ...) But all the tutorials show only the hopeless example: onlytrue
orfalse
.Could anyone help me with a small useful example using this templates?