help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

g++ 3.4.6 acting strangly with template code


From: Keith Halligan
Subject: g++ 3.4.6 acting strangly with template code
Date: 15 Mar 2007 11:26:57 -0700
User-agent: G2/1.0

I've some code here that works fine on g++ 3.2.3, and when I compiled
it under g++ 3.4.6, it failed to compile.  Here is a basic layout of
the code (albeit very simplified).

class Base
{
   public:
      class InnerBase
      {
         public:
             InnerBase(const Base* ) { }
      };


};


template<class T>
class derived_first : public Base::InnerBase
{
   public:
      derived_first(T* p = 0);
};

template<class T>
derived_first<T>::derived_first(T* p)
  : Base::InnerBase(p)
{
}


class derived_second : public Base
{
  public:
     derived_second() {}

}

int main(int argc, char** argv)
{
   derived_first<derived_second> d;

   return 0;
}

Whenever I compile it with gcc-3.4.6 it complains about the
Base::InnerBase(p) line.
Saying that there's no match for it
derived_first<T>::derived_first(T*) [T = derived_second]
No call that matches
nearest match: Base::InnerBase(Base*)

I've heard that gcc/g++ 3.4 is more strict with templates, using the
two-phase lookup procedure, which seems to break a lot of old template
code.  I'm just wondering is there anyway to get this to compile
correctly under the new standard.

For now I've a small hack in. I added the constructor
Base::InnerBase(void* v), and it works fine (but I'd like to get the
correct constructor called).

Any help is much appreciated.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]