How to know if the argument that is passed to the function is a class, union or enum in c++?
Posted
by
Narek
on Stack Overflow
See other posts from Stack Overflow
or by Narek
Published on 2011-01-16T12:25:57Z
Indexed on
2011/01/16
12:53 UTC
Read the original article
Hit count: 151
I want to define an operator<< for all enums, to cout the value and print that it is an enum like this:
code:
enum AnyEnum{A,B,C};
AnyEnum enm = A;
cout << enm <<endl;
output:
This is an enum which has a value equal to 0
I know a way of doing this with Boost library by using is_enum struct. But I don’t understand how it works. So that's why, in general, I am interested how to identify if the veriable is a class type, union type or an enum (in compile time).
© Stack Overflow or respective owner