Topic: A thought about Core Issue 459.
Author: pongba@gmail.com
Date: Fri, 24 Nov 2006 15:07:02 CST Raw View
459 . Hiding of template parameters by base class members.
Lately I read through this issue and found some interesting ideas and
observations there.
Though, I thinks there might be something important that hadn't been
considered.
Here's my opinion:
If the user declares a class template with template parameter named T,
then when he/she refers to "T" in this class template, either he/she
wants to use this template parameter, or he/she just *know* clearly
that "T" ought to be some member type in one of its base classes.
In the later case, the only place where he/she could use the template
parameter T is in the base class list specification(i.e.
template<typename T> struct D: B<T> {... }; ). Since the use of
template parameter T is so limited in this case, I want to ask who
would do that, it doesn't seem to do any good. Also, in this case,
he/she could and should just use the qualified T(i.e. typename
B<...>::T).
The thing is, why would anyone declare a template parameter and never
use it(except, maybe, in the base class list specification, but in this
case he can just qualify all the other use of T).
So, this leaves us with the first case. But then the intention of
him/her using "T" would definitely be using the template parameter T,
he/she who does so would *definitely* NOT want some occasional member
type T in some unfortunate base class to disturb this map.
However, according to the current rule, the user would have no way to
protect himself from this disaster( provided that the intention of him
is as the later case, coz the first case should be very few and odd;
and even if that happens, a simple qualification of all the other use
of T would do the job and make the code clearer).
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]