Re: Problem with 'template' as a qualifier
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Rodolfo Lima wrote:
It seems that the '::' tells the compiler that what precedes it is a
type (when the token is followed by another ::), so the 'typename'
qualifier is only to disambiguate the last token.
In a more general case, the X in X::Y can be a namespace or a type (I
hope I'm not forgetting something).
In X::Y::Z when X has already been identified as a type (templated, so
its internals are unknown), I think Y might still be a namespace, but
I'm very unsure (haven't tested). Anyway, some of the compilers I use
insist on being told that Y is a type.
In X::template Y<T>::Z it is even clearer that Y<T> must be a type, but
I wasn't sure the compiler didn't still need to be told. I've never
been clear on what typename qualifies and when you need it.
My rant about 'typename' is that we have to tell the compiler that
we're dealing with types even if it makes no sense for it to be a value.
If rants did any good for the glaring flaws in the C++ standard, I'd be
ranting quite a bit. The only real rant is about the standards
committee placing certain pointless extremes of intellectual purity
above the usability of the language.
Anyway, I thought your issue was with template rather than with
typename. I'd prefer if the standard made the compiler deduce template
in cases that can't be parsed any other way, rather than make the
programmer clutter the code with it. But for template, at least I
understand why deducing it would be hard on the structure of the
compiler and I understand when it is needed and what it qualifies.
[Index of Archives]
[Linux C Programming]
[Linux Kernel]
[eCos]
[Fedora Development]
[Fedora Announce]
[Autoconf]
[The DWARVES Debugging Tools]
[Yosemite Campsites]
[Yosemite News]
[Linux GCC]