Boost logo

Boost :

Subject: Re: [boost] [Review] Type Traits Introspection library by Edward Diener starts tomorrow Friday 1
From: Edward Diener (eldiener_at_[hidden])
Date: 2011-07-03 08:21:01


On 7/3/2011 7:05 AM, John Bytheway wrote:
> On 01/07/11 03:08, Joel Falcou wrote:
>> According to the schedule, review for the Type Traits Introspection
>> library by Edward Diener
>> starts this friday and run till July 10th.
>
> This is not a review, but some initial thoughts:
>
> You mention early in the docs the risk of ODR violations from declaring
> the same metafunction more than once. It seems to me that this is very
> likely to occur when multiple libraries want to introspect the same
> names. For example, if two libraries both include
>
> BOOST_TTI_HAS_TYPE(type)
>
> then I will not be able to use both these libraries in my program; is
> that right?

Correct.

>
> This seems a serious deficiency. I feel it would be better to generate
> these macro metafunctions in a namespace specific to the code that wants
> to use them, rather than putting them all in boost::tti. That would
> essentially eliminate the risk of cross-library ODR violations. What
> is your motivation for putting all the macro metafunctions in the same
> namespace?

You have made a very good point.

My intention, evidently misguided, was to put the generated
metafunctions in the boost::tti namespace to avoid polluting the global
namespace. But I see now that I should not have added a namespace at all
and the end-user could then use the macros in whatever namespace he
wants in order to avoid ODR violations, and/or just use the complicated
macro form to create a unique name for the metafunction. Actually, of
course, that still could be done, but a full metafuncion name of
'anamespace::boost::tti::has_type_mytype' is more gruesome than
'anamespace::has_type_mytype'.

Thanks for pointing this out.


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