On Friday 25 April 2014 09:25:45 Dominique Devienne wrote:
But what bothered me a little was the note about the fact that pretty_name() was not consistent across platforms/compilers.
This means you can't depend on it for generating a type-name-based factory registration via a template taking the type to be instantiated, and deducing the registration name from the type, in a way that will be cross-compiler or cross-platform, w/o some kind of post-processing to remove possible struct/class prefix, or namespace prefix if desired. It's only a problem when the names are coming at runtime from external strings, but that's a common enough use-case of factories, to want boost::typeindex to support it, no? Thus I'd request a safe_name() / consistent_name() method, that does the pretty_name() post-processing once and for all, to yield ns_name::type_name for example, or perhaps even a std::pair with NS name as .first, and type name as .second.
There is generally no way to obtain a portable type name. Each compiler and platform has its own mangling rules and there are no rules for the demangled type names whatsoever. Attempting to support translation from all platform- specific formats to some "unified" format is hardly feasible, IMHO. The best way of achieving your goals is to avoid using type names altogether and use regular strings in known format, UUIDs or whatever other IDs that have stable format.