Boost logo

Boost :

From: Giovanni Bajo (giovannibajo_at_[hidden])
Date: 2004-02-13 19:06:47

David Abrahams wrote:

>> struct A {
>> typedef int M;
>> template <class M>
>> void foo(void) {
>> M m; // which M is this?
>> }
>> };
>> I know the C++ committe is discussing this issue at this moment. The
>> argument would be that "M" names the typedef because it's "more
>> stable" than the template parameter (which could get renamed in an
>> out-of-class definition). See also for a
>> detailed discussion.
> I'm sorry, but that's insane from a usability POV. C++ already has
> too many places where something far away can be chosen instead of the
> "obvious" alternative close by (see ADL).

I'm not advocating that, I'm just saying that it's how GCC currently works and
it seems to be a gray area of the standard. My personal opinion is that GCC is
wrong: I agree with you that the template parameter should be found on name

> Introducing a typedef in an
> enclosing namespace should not affect the meaning or well-formedness
> of a use of a template parameter, especially because this sort of
> thing is liable to happen due to changes in #includes.

We're not speaking of namespace scope but class scope, though. It's a bit
harder to change things at class scope. Anyway, we both agree that it's insane
for C++ to behave like this, so never mind :)

Giovanni Bajo

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