I have a template function in C++ that basically writes values to an XML file, for validation purposes I wish to write out the variable type as well as its value. I am currently using typeid(T).name() which works great for int, double etc but I want a special case for char arrays and std::string so that it always writes out "string" or something more meaningful than:
class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >
or
char const [2]
Any ideas on how I can do this in an elegant way?
My code (cut down) looks like this (not the function is template only)
template <typename T> bool SetValue(const std::string §ionName, const std::string &valueName, const T &value)
{
myXMl->AddAttribute(TYPE_DEF,typeid(T).name());
return true;
}