Hey, question..   Just wondering if gcc is supposed to behave this way now.

For example, I have a template:

template <class T> class foo
{
...
   void method1(T a1) {...}

   T method2() {...}
...
};


Notice, method1 accepts a parameter of type T and method2 returns a value of type T.

Well, if foo is instantiated as foo<int>  then everything is fine.

However, lets say we typedef an array type and instantiate foo with it...

typedef int bar[10];             //  bar is a type: int[10]
foo<bar> f;


Now, method1 is accepting an array parameter (fine), but method2 is returning an array value (error)

In gcc-3, there was no error until you tried to call f.method2(), but in gcc-4 it gives the error when foo<bar> is instantiated whether the method is called or not. I used this feature intentionally in gcc-3, but I wanted to know if it's an ANSI thing one way or another. And if it's not ANSI compliant now, then I guess it needs to be fixed in gcc.

Thanks,
 Davy




Reply via email to