Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-05-07 17:06:18


"Arkadiy Vertleyb" <vertleyb_at_[hidden]> writes:

> "David Abrahams" <dave_at_[hidden]> wrote
>
>> Any time a template is instantitated, all names in its definition must
>> map to the same entities in each translation unit, or you violate the
>> ODR. By definition, names in the unnamed namespace refer to distinct
>> entities in each translation unit.
>
> Does this mean that it's not allowed to use anonimous namespace-level names
> inside templates?

Unless those, too, are in the unnamed namespace, I think that's
technically correct. You can probably get away with it, though.

> I assume there also should be problems with non-template classes,
> too, if anonimous namespace-defined names are used inside the body
> of such a class...

Yes, definitely.

> OTOH, you said "all names in its definition". Does this also mean "all
> names used to produce this definition"?

I think so.

> Because if we use "typeof" inside such template, it would still
> resolve to the same type in different translation units (after all
> the metaprogramming used to produce this type is done).

I understand that. I think you can get away with it, but that it's
not legal. This is another reason I think Boost.Bind's placeholders
have to leave the unnamed namespace.

> IOW, such templates in different translation units will be absolutely the
> same, although in each translation unit the compiler will have to
> instantiate different intermediate classes in order to produce them.

Right.

> Do you still think this should be a problem?

"_Should_ be?" no, I never did. I just think it's technically a
violation of the rules.

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com

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