Gcc complain about typename

X

Xavier Decoret

I got the following piece of code:

template <class T,class V>
class ClusterLeaf : public Cluster<T,V>
{
public:
// ...
protected:
friend class Cluster<T,V>;
friend class Cluster<T,V>::const_iterator;


The last line compiles fine on gcc3.3 but issues a warning that is:
cluster.h:109: warning: `Cluster<T, V>::const_iterator'
is implicitly a typename

Before gcc3.3 I was using an earlier version (gcc3 or maybe gcc2.96) and
the incriminated line was actually changed by:
friend typename Cluster<T,V>::const_iterator;

But now that I use gcc3.3, the above line won't compile with a warning
saying friend requires the class keyword.


I know it looks compiler specific but the question is actually: what
should be the proper way of specifying this. Does friend require "class"
all the time according to the standard? What about typename? As far as I
understood, typename is required when the compiler could mistake the
type (the example of T::type* p which can actually be a multiplication).
But after the friend keyword, it should know a type is coming?

Thanks for any element that would help identify the problem and
eventually check with the gcc guys.
--
+-------------------------------------------------+
| Xavier Décoret - Post Doct |
| Graphics Lab (LCS) - MIT |
| mailto: (e-mail address removed) |
| home : http://www.graphics.lcs.mit.edu/~decoret|
+-------------------------------------------------+
 
D

Dhruv

I got the following piece of code:

template <class T,class V>
class ClusterLeaf : public Cluster<T,V>
{
public:
// ...
protected:
friend class Cluster<T,V>;
friend class Cluster<T,V>::const_iterator;

AFAIK, Should be: friend class typename Cluster<T,V>::const_iterator;

I might be wrong here, though. Because as you said, after friend, the
compiler could know that a type is coming.


-Dhruv.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top