|
Boost : |
From: Gabriel Dos Reis (gdr_at_[hidden])
Date: 2004-02-16 16:21:58
David Abrahams <dave_at_[hidden]> writes:
| 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 then, your remark about "would be horrible for generic program"
is, ahem, puzzling. You still did not explain why.
| > 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.
What is bizarre and inconsistent about it and is not with the other
alternatives you care to name? This question is not rhetorical.
When you register strong opinons about a technical issue or throw in
the air fashionable words like "generic programming", the least that
could be expected is that you provide technical explanation.
| Shall we outlaw:
|
| struct Base { static int x; };
|
| struct Derived : Base {
| void f(int x) {} // Horrors! we're masking a base class member!
If you happen to pause a second and have look at the issue at hand, I'm
confident that you'll see the difference between the case we're
discussing and your example.
| };
|
| Sorry for the sarcasm;
And, I'm pretty sure you know sarcasm is not appropriate for tehcnical
discussions.
-- Gaby
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk