I want to get the type name and print it for debugging purposes. I am using the following code:
#include <cxxabi.h> inline const char* demangle(const char *s) { abi::__cxa_demangle(s, 0, 0, NULL); } template<typename T> inline const char* type_name() { return demangle(typeid(T).name()); }
This works well, but I think the overhead is superfluous. Is there a way to get a human-readable form of type identifiers that is computed at compile time? I am thinking of something that looks like this:
boost::mpl::type_name<MyType>::value
Which will return the string constant of the type name.
As a question (not so strict): is it possible to perform line processing with boost :: mpl?
source share