char const* is a pointer to const char , but the pointer itself is not const . To remove a constant from a specified type, you can do this:
std::add_pointer<typename std::remove_const<typename std::remove_pointer<T>::type>::type>::type
Or alternatively:
typename std::remove_const<typename std::remove_pointer<T>::type>::type*
We remove the pointer from const char* to get a const char , then remove the const to get a char , then add the pointer back to get a char* . Not particularly beautiful. To check:
typedef const char * type_before; std::cout << typeid(type_before).name() << std::endl; typedef typename std::remove_const<typename std::remove_pointer<type_before>::type>::type* type_after; std::cout << typeid(type_after).name() << std::endl;
With g ++ on my system, this produces:
PKc Pc
This should give you a hint about what PKc means. P for pointer, c for char and K for konst ;)
source share