How do I get the type of a variable?
In C++, how does one find the type of a variable?
Solution 1:
You can use the typeid operator:
#include <typeinfo>
...
cout << typeid(variable).name() << endl;
Solution 2:
For static assertions, C++11 introduced decltype
which is quite useful in certain scenarios.