Boost logo

Boost :

Subject: Re: [boost] [TypeIndex] Peer review period for library acceptance begins, ending Thurs 21st Nov
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2013-11-16 14:46:21

On Saturday 16 November 2013 22:15:18 Antony Polukhin wrote:
> 2013/11/16 Andrey Semashev <andrey.semashev_at_[hidden]>
> > On Saturday 16 November 2013 19:46:25 Antony Polukhin wrote:
> > > 2013/11/16 Andrey Semashev <andrey.semashev_at_[hidden]>
> <...>
> I don't think there's any use for template_index, as I outlined in my
> > review.
> > type_index already has all the functionality and should work whether or
> > not
> > RTTI is enabled.
> template_index and type_index are two different types intentionally. It's
> the last attempt to notify user that he has done something wrong:
> // This is an interface of some library. Library is compiled without RTTI,
> // user uses this header with RTTI on.
> void some_function(boost::type_index& ti);
> If template_index and type_index are two different types and
> BOOST_TYPE_INDEX_FORCE_NO_RTTI_COMPATIBILITY is not defined, then user will
> get a linker error on GCC. If those two classes were exactly the same type,
> there'll be no link error. But user will get undefined behavior with hard
> detectable errors.

That does not require two different types, such as template_index and
type_index. You can define a single type_index in an inline namespace, which
name depends on the use of native RTTI. For C++03, a regular namespace and a
using declaration would suffice. That way all user's code will just always use
type_index, and there will be linking errors in case of configuration

Having two different interface classes instead divides the world in two parts
and creates integration problems for users. Imagine library A uses
template_index and library B uses type_index. How would these libraries
coexist in a user's application, which is happy to use native RTTI? And what
are the guidelines for library writers on choosing between these two types?

IMO, there should be a single type_index class, which should work in both

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