Boost logo

Boost :

From: Gabriel Dos Reis (gdr_at_[hidden])
Date: 2004-02-16 20:04:47

David Abrahams <dave_at_[hidden]> writes:

| > What is bizarre and inconsistent about it and is not with the other
| > alternatives you care to name?
| As I expected my example below to demonstrate, I think it's
| inconsistent with the way names from non-dependent base classes are
| dealt with when masked by function parameter names.

But function parameters are not template parameters vice versa. And
you should not expect them to behave the same without providing
technical reasons why such expectations may take place.

The fundamental difference between them is the places where they are
declared. The scope of template-parameters *encloses* the template --
that is why members of non-dependent bases hide them -- whereas member
functions *are enclosed* by the scope (non-dependent) base classes
-- which is why those function parameters can hide members in base

An action that would be consistent is to leave the current rule as is
-- but some people been saying that that consistent behaviour goes
against their intuition.

| Up till now, the only way that changing the name of a private member
| could break a derived class (AFAIK) is if the member were virtual.

No, that assessment it not true. Because name lookup happens before
(overloading if applicable) and access checking applies, changing any
name in the base (whether private or not is irrelevant) has the
potential to break a derived class.

  class B { int X; }

  stryct Y { };

  struct D : B {
    Y y;

If you the name "X" in B to "Y"; you break D.

I'm adding nothing here. It is a general issue. If you want to
complain about it, fine. But, that is not my invention and don't
pretend I'm being innovative here or adding an unsual situation.

| IIUC your proposed rule would add another one.
| > This question is not rhetorical. When you register strong opinons
| > about a technical issue or throw in the air fashionable words like
| > "generic programming",
| Generic Programming went out of style around here about 7 weeks ago.
| It's so, like, 2003.


| > the least that could be expected is that you provide technical
| > explanation.
| I just misunderstood your proposal, Gaby, and in that light I thought
| the meaning behind my remarks to be "obvious".
| > | 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.
| Of course I see the difference; they use different language features.
| I also see the analogy. I honestly don't see why the other case would
| warrant a diagnostic, while this one doesn't. Why is the difference
| between a member template parameter and a function parameter
| significant?
See a difference at the beginning of this message.

-- Gaby

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