Boost logo

Boost :

Subject: Re: [boost] [type_index] C++03 implementation in boost?
From: Antony Polukhin (antoshkka_at_[hidden])
Date: 2012-07-03 12:59:34


2012/7/3 Agustín K-ballo Bergé <kaballo86_at_[hidden]>:
> The documentation needs some work. There are a considerable number of typos,
> most notable 'retruns' -> 'returns'.

Could not find it. In what file is it?

> Hashing the type names could be suboptimal compared to a native
> implementation of `type_info::hash_code`. The compiler knows the entire set
> of values, so it *should* be able to provide a perfect hash function. You
> should use the native implementation in those cases where its available.

You are right. I looked through the headers of GCC and found that it
has optimized version of hash_code(). Fixed hash_code() in type_index.

> I'm no expert in locales, but I believe your implementation of `before` may
> be susceptible to global locale changes.

Looks fine for me.

> I'm not particularly keen on `name` and `name_demangled` returning different
> string types. Would it make sense to have `name_demangled` cache the result,
> and return a `char const*` instead?

Caching the result will increase size of type_index object, and that
would lead to slower copying/assigning/constructing of type_indexes.
Demangled names are usually used in non performance critical sections
(in error reporting; outputting user readable data to stream) and
usually only once. So I think that not using caching is a little bit
better than using it.

Thanks for your advices!

-- 
Best regards,
Antony Polukhin

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