fork download
  1. #include <iostream>
  2. #include <typeinfo>
  3.  
  4. template <typename T>
  5. char const * type_name()
  6. {
  7. return typeid(T).name();
  8. }
  9.  
  10. int main() {
  11. int a[10];
  12.  
  13. std::cout << "type name for int[10]: " << type_name<int[10]>() << std::endl
  14. << "type name for int*: " << type_name<int*>() << std::endl
  15. << std::endl
  16. << " a is " << type_name<decltype(a)>() << std::endl
  17. << "+a is " << type_name<decltype(+a)>() << std::endl;
  18.  
  19. return 0;
  20. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
type name for int[10]: A10_i
type name for int*:    Pi

 a is A10_i
+a is Pi