[C++-sig] wrapping typedef equivalent types

David Abrahams dave at boost-consulting.com
Fri Oct 21 14:47:14 CEST 2005


"Ralf W. Grosse-Kunstleve" <rwgk at yahoo.com> writes:

> --- David Abrahams <dave at boost-consulting.com> wrote:
>> > I.e. the trick is to compare boost::python::type_info(typeid(X)).
>> 
>>   if ( boost::is_same< std::size_t, unsigned >() )
>> 
>> would be a whole lot cleaner, and would often generate less code since
>> the check can be made at compile-time.
>
> I see. Thanks!
>
> I chose the boost::python::type_info(typeid(X)) approach because this is
> exactly how the Boost.Python registry determines equivalence.

Well, you should be using type_id<X>() rather than writing it out
longhand.

> boost/python/type_id.hpp has all kinds of platform-specific adjustments, e.g.
> the "signed int" vs. "int" workaround for "Older EDG-based compilers". Is it
> safe to assume that boost::is_same<> is true if and only if
> boost::python::type_info instances compare equal?

Except on implementations that we can effectively consider buggy, yes.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com




More information about the Cplusplus-sig mailing list