C++ PATCH: Towards two-phase name lookup and other things...
Phil Edwards
phil@jaj.com
Fri Jan 17 03:57:00 GMT 2003
On Fri, Jan 17, 2003 at 02:33:09AM +0100, Gerald Pfeifer wrote:
> On Thu, 16 Jan 2003, Mark Mitchell wrote:
>
> > (The standard library did a lot of:
> >
> > template <typename T> struct B { int i; };
> > template <typename T> struct D : public B<T> { void f() { i = 3; } };
> >
> > which is not legal. You meant to say "this->i".)
> >
> > Y'all will probably make me add a helpful error message like the
> > typename one for this case too.
>
> I have to admit I didn't now about the this-> thingie being required
Without a helpful error message, this is definitely going to cause bug
reports ("But it works with normal classes! Templates suck! Wah!"),
and I don't really blame the users for doing so. In my experience, most
C++ coders still don't know that specialization can declare a completely
different structure than that declared by the primary template. (It's
not exactly intuitive to do so, after all.)
The library has to do lots of "this->" everywhere already to avoid Koenig
lookup. The last time I walked the library code looking for places where we
were forgetting to prefix with "this->", I admit this only-with-templates
rule completely slipped my mind.
Phil
--
I would therefore like to posit that computing's central challenge, viz. "How
not to make a mess of it," has /not/ been met.
- Edsger Dijkstra, 1930-2002
More information about the Gcc-patches
mailing list