fork download
  1. #include <iostream>
  2. #include <typeinfo>
  3. #include <cxxabi.h>
  4.  
  5. std::string dm(const std::string& name)
  6. {
  7. int status;
  8. return std::string(abi::__cxa_demangle(name.c_str(), 0, 0, &status));
  9. }
  10.  
  11. using namespace std;
  12.  
  13. template <typename T>
  14. using remove_const_if_pointer_to_const =
  15. std::conditional_t<std::is_pointer<T>::value,
  16. std::add_pointer_t<std::remove_const_t<std::remove_pointer_t<T>>>,
  17. T>;
  18.  
  19.  
  20.  
  21.  
  22. int main() {
  23.  
  24. using A = int;
  25. using B = int*;
  26. using C = const int*;
  27.  
  28. std::cout << dm(typeid(remove_const_if_pointer_to_const<A>).name()) << std::endl;
  29. std::cout << dm(typeid(remove_const_if_pointer_to_const<B>).name()) << std::endl;
  30. std::cout << dm(typeid(remove_const_if_pointer_to_const<C>).name()) << std::endl;
  31.  
  32. return 0;
  33. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
int
int*
int*