Boost logo

Boost :

Subject: Re: [boost] [Boost-users] [typeindex v3.0] Peer review begins Mon 21st ends Wed 30th
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2014-04-27 10:43:27


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.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk