|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2004-02-16 16:04:27
Brian McNamara <lorgon_at_[hidden]> writes:
> Apologies ahead of time if I am putting words in anyone's mouth.
>
> I think Dave wants to imply that the class T in his example is not
> allowed to have a member named U according to Gaby's proposed rule.
That's what I thought he meant.
> But this isn't how the rule would work; the way I see it, _these_:
>
> struct Base { typedef int U; };
>
> template <class U>
> struct Derived : Base { }; // illegal
>
> struct Derived2 : Base {
> template <class U>
> void f(U u) {} // illegal
> };
>
> would be illegal ("the name U already has another meaning; choose
> another name for your template parameter"), whereas _these_:
>
> struct Base { typedef int U; };
>
> template <class B, class U>
> struct Derived : B { };
> /* ... Derived<Base> ... */
>
> template <class B>
> struct Derived2 : B {
> template <class U>
> void f(U u) {}
> };
> /* ... Derived2<Base> ... */
>
> are both fine, since Base's "U" is hidden by virtue of being a dependent
> name. There is still an issue of what happens if one of these last two
> classes issues a "using B::U" in its body; presumably then "U" ought to
> become outlawed as a valid template parameter name.
>
> Just my two cents here...
OK, I think I understand now. I think it's a bizarre and inconsistent
rule. Shall we outlaw:
struct Base { static int x; };
struct Derived : Base {
void f(int x) {} // Horrors! we're masking a base class member!
};
Sorry for the sarcasm; it'll wear off by tomorrow.
-- Dave Abrahams Boost Consulting 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