
"Giovanni Bajo" <giovannibajo@libero.it> 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 http://gcc.gnu.org/PR13967 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 www.boost-consulting.com