fork download
  1. #include <iostream>
  2. #include <typeinfo>
  3. #include <cxxabi.h>
  4.  
  5. using namespace std;
  6.  
  7. template <typename T>
  8. const char* name_for_type (T& type) {
  9. int status;
  10. return abi::__cxa_demangle(typeid(type).name(), 0, 0, &status);
  11. }
  12.  
  13. int main() {
  14. char test[] {1,2,3,4};
  15. char test2[] {1,2};
  16. char* penis = "peins";
  17.  
  18. cout << name_for_type(test) << endl;
  19. cout << name_for_type(test2) << endl;
  20. cout << name_for_type(penis) << endl;
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
char [4]
char [2]
char*