Review Request: C++-Parser: Eat typename

David Nolden zwabel at googlemail.com
Thu May 6 08:28:33 UTC 2010


2010/5/6 Esben Mose Hansen <kde at mosehansen.dk>:
> On Wednesday 05 May 2010 14:34:52 David Nolden wrote:
>> Currently we simply have no use for the "typename" keyword. At some point I
>> have to check out in the language specification why it is needed
>> sometimes, but I think that KDevelop understands such cases even without
>> it.
>
> It is mostly the "dependent type" problem, that is, when the type is not
> available until instantiation. E.g.
>
>
> struct A {
>  typedef int cheese;
> };
>
> template<typename T>
> struct B {
>  typedef typename T::cheese stelton;
> };
>
> I had a book once that showed an example where not requiring the keyword could
> lead to the compiler picking the wrong definition of something, but I can't
> remember it offhand, and the book disappeared some time ago.

At least for this case, KDevelop will understand it anyway. I know
that "typename" is sometimes required, and I think the main reason is
to let the C++ compiler know that it's dealing with a type, even if it
hasn't been instantiated yet. For example, the referenced object could
also be a variable or something like that. However all of the cases I
know should work in KDevelop without that knowledge, as the decision
is delayed until the instantiation. Still I'm sure that it's possible
to construct a case where even KDevelop won't be able to do it
correctly without that info, but I guess I will just wait until
someone comes up with such a case at some point in a bug-report.

Greetings, David




More information about the KDevelop-devel mailing list