Gcc complain about typename

Discussion in 'C++' started by Xavier Decoret, Jul 4, 2003.

  1. 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: |
    | home : http://www.graphics.lcs.mit.edu/~decoret|
    +-------------------------------------------------+
     
    Xavier Decoret, Jul 4, 2003
    #1
    1. Advertising

  2. Xavier Decoret

    Dhruv Guest

    On Fri, 04 Jul 2003 00:33:56 -0400, Xavier Decoret wrote:

    > 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.
     
    Dhruv, Jul 4, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sklett
    Replies:
    1
    Views:
    397
    Chad Crowder
    Apr 3, 2004
  2. Pronto
    Replies:
    0
    Views:
    392
    Pronto
    Sep 15, 2003
  3. Roy Yao
    Replies:
    4
    Views:
    382
    Roy Yao
    Aug 21, 2003
  4. Dan Christensen
    Replies:
    3
    Views:
    256
    Peter Hansen
    Jul 13, 2004
  5. Jakob Bieling

    Q: typename or not typename?

    Jakob Bieling, Mar 14, 2006, in forum: C++
    Replies:
    2
    Views:
    356
    Rolf Magnus
    Mar 14, 2006
Loading...

Share This Page