Re: What's wrong with this class temlate's typedef?

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

 



On 7/22/08, Rob <spamrefuse@xxxxxxxxx> wrote:
> The following code snippet is a stripped down version of what I use
> in my code.  Last time I compiled this code is several years ago......
> I tried to compile it again today with GCC 4.3.0 (20080428), but
> now I get an error message:
>
> --------------------------------------------------------
> template <typename T = double, unsigned int d = 3> class A { };
>
> template <typename T = double> class B : public A<T, 4> {
>    typedef A<T, 3> A;
> };
>
> int main () { B<double> *object; };
> --------------------------------------------------------
>
> Error message:
>   4: error: declaration of 'typedef class A<T, 3u> B<T>::A'
>   1: error: changes meaning of 'A' from 'class A<T, 3u>'
>
> Here, I could use class "A" as a substitute for "A<T,3>" only within
> the class B.  That used to work in the past.

The code has never been legal, but has worked because (1) the
compiler did not check and (2) the compiler processed declarations
in such a way that it did what you wanted.

> Is there a way to get this compiled again without having to change
> all the class names in the typedef?

Yes, qualify the definition of the typedef.

  typedef ::A<T, 3> A;

-- 
Lawrence Crowl

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux