
I did some searching but did not find anything that directly addresses my issue. I have been working with the QT library and I wanted to optimize boost::lexical_cast for QString. My goal is to have the speed of direct conversions (as QString provides specialized methods for char* and std::string) while keeping the convenience of using lexical_cast by reflex. My results (which seem to work) look like this: namespace boost { template <> inline QString lexical_cast<QString, char const *>(char const * const& src) { return src ? QString(src) : QString(); } template <> inline QString lexical_cast<QString, char *>(char * const& src) { return src ? QString(src) : QString(); } } Is this an appropriate / recommended approach? If not, is there a better one? There are some other cases of a similar nature that I would like to optimize as well.