Boost logo

Boost :

From: Alexander Nasonov (alnsn-boost_at_[hidden])
Date: 2005-05-26 17:09:34

Arkadiy Vertleyb writes:
> Hi Sasha :)

> Why "(other)"? I believe they are the same in the same TU...

Now I see. In

An unnamed namespace definition behaves as if it were replaced by

namespace unique { /* empty body */ }
using namespace unique;
namespace unique { namespacebody

where all occurrences of *unique* in a translation unit are replaced by *the
same identifier* and this identifier
differs from all other identifiers in the entire program.

Somehow I missed *the same identifier*. How could I ever program for years
without knowing this?

> > namespaces. Is it intentional?

> Yes.

> Automatic ID generation leads to potential ODR violation, since, depending
> on the order of inclusion, the same template specializations can be
> generated with different IDs, and therefore with different bodies. This
> workarounded by placing them into anonimous namespaces, so that thay are
> different in different TU, and so not the subject to ODR.
> This question was discussed in the past, and it was decided that we can
> with this as long as we have a specific test that verifies that compilers
> don't really care. We have such test, and at some point Martin Wille
> me by running it on como, which is considered to be the most strict
> compiler. Of course it's also a part of our regular test.

Yeah, I remember this discussion.

One idea came to my mind. In order to avoid ODR violations, can we switch
from definitions to declarations?

Every BOOST_TYPEOF_REGISTER_TYPE macro could add overloaded reg_entry
function which encodes a given type T:

template<class T>
char (& reg_entry(identity<T>) ) [CODE1][CODE2] ... [CODE50];

> I don't know how noticable this is in the current doc, though.

I don't care much about a quality of documenation for now. Lack of it may be
even better because it could protect from overusing the library. This
reminds me of the fact that a first version of MPL was introduced

Thanks Arkadiy and Peder for great library!

Alexander Nasonov

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