type of int is int
type of i is int
type of a is int [2][3]
type of EmptyClass is class EmptyClass
type of c is class EmptyClass
type of dump<int, 8> is void __cdecl(int (&)[8])
#include <iostream>
#include <typeinfo>
class EmptyClass {
// empty, boring class
};
inlinedouble sqr(double x) {
return (x * x);
}
template<typename TElem, int NElems>
void dump(TElem (&a)[NElems]) {
for(int i = 0; NElems > i; ++i) {
std::cout << " " << a[i];
}
}
#define REPORT_TYPE(V) \
std::cout << "type of " #V " is " << typeid(V).name() << "\n"
int main() {
int i = 0;
int a[2][3] = {0};
EmptyClass c = EmptyClass();
REPORT_TYPE(int);
REPORT_TYPE(i);
REPORT_TYPE(a);
REPORT_TYPE(EmptyClass);
REPORT_TYPE(c);
// template itself does not have an actual type -- just its instantiations
// too lazy to concoct macro solution for this:
std::cout << "type of dump<int, 8> is " << typeid(dump<int, 8>).name() << "\n";
return 0;
}