Topic: Unnecessary typename qualifications?
Author: bparker@gil.com.au (Brian Parker)
Date: 1997/03/28 Raw View
Hi all,
I have recently been "typename"-ifying my code and I have come across
situations where I am unclear as to whether they are required.
The first case is in the parameter list of a template function
definition. It would seem that typename would be redundant here as a
type name is clearly required. In fact, the Dec. draft gives the
following example (page 14-38 [temp.deduct] paragraph 10) which would
seem to indicate that they are not required-
template<int i, typename T>
T deduce(A<T>::X t, T t, B<i>::Y y)
{
...
}
which is as one would expect, except that 14.6 [temp.res] paragraph 4.
only lists base-specifiers and mem-initializers as contexts in which a
qualified name is implicitly assumed to be a type name.
I think that parameter declarations of template functions should be
added to that list.
The second case is typedefs.
In fact in my code, I have found that most of the added "typename"'s
were required in class typedefs even though, again, in this case they
would seem to be redundant as a type name is clearly required. The
draft has several examples showing that typename is required in this
case, but I think that adding typedef declarations to the list of
implicitly-assumed contexts would save a lot of typing.
Any comments? Have I missed examples where typename is actually needed
for disambiguation in these cases?
,Brian Parker (bparker@gil.com.au)
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]