Boost logo

Boost :

Subject: Re: [boost] [TypeIndex] Peer review period for library acceptance begins, ending Thurs 21st Nov
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2013-11-13 02:58:30


On 13/11/2013 20:46, Quoth Antony Polukhin:
> This is almost impossible: different compilers decorate names differently.
> This means that for each compiler we need to write parser/lexer that:
> * puts const, volatile, rvalue, reference at correct position (always after
> the type or always before)
> * strips away class, struct, __cdecl*
> * unifies template parameters representation
> * makes other unifications (array representations, wchar_t and __wchar_t
> unifications and so on...)
>
> This may be done some day and `name_portable()` method can be added. But
> I'm afraid this won't happen soon.

Granted it's hard to sort out all the cases. But solving the common
cases for the common compilers (eg. leading struct) should be easy, and
people could chip away at the other cases over time if they cared to.

> According to C++03 and C++11 Standard type_info::name() must return const
> char*. Getting readable name requires some work and an internal buffer
> inside boost::type_info. This looks like a bad solution (so "raw_name()"
> and "name()" won't fit).

But you're not implementing std::type_info, you're implementing
boost::type_info, so you should be free to return a std::string if you
feel like it. You're already changing the behaviour on MSVC, because
std::type_info::name returns the long name but boost::type_info::name
returns the short name.

Or how about:
   * const char *name() : returns whatever std::type_info::name does [if
RTTI]
   * std::string short_name() : returns the raw/mangled name
   * std::string long_name() : returns the long/demangled name

Or flip the components (name_short and name_long) if you prefer; it
sorts better but reads worse that way, I think.

(With RTTI disabled, all three would probably return the same value.)


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