Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-02-13 17:54:41

"Giovanni Bajo" <giovannibajo_at_[hidden]> writes:

> 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). 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.

Fortunately, it seems that the discussion ends by kicking the problem
back over to the CWG and I can only hope that they "do the right
thing" here.

Dave Abrahams
Boost Consulting

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