Boost logo

Boost :

Subject: Re: [boost] [TypeIndex] Peer review period for library acceptance begins, ending Thurs 21st Nov
From: Antony Polukhin (antoshkka_at_[hidden])
Date: 2013-11-13 04:28:48

2013/11/13 Gavin Lambert <gavinl_at_[hidden]>

> 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.

This will break the ability of TypeIndex to be a drop-in replacement for

boost::any a;
const char* m = a.type().name(); // with boost::type_info this would be

> Or how about:
> * const char *name() : returns whatever std::type_info::name does [if
> * 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.)

This is a good idea, thanks! Using it less user code will be broken.

Do you like the following names:
* const char* name() // minor behavior change on MSVC
* const char* name_mangled() // this method must be added
* std::string name_demangled() // remains exactly the same

Best regards,
Antony Polukhin

Boost list run by bdawes at, gregod at, cpdaniel at, john at