Explicity template specialization issue

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

 



Hi,

The following code is giving errors while compiling with GCC 4.5.

Header File: declaration of template class.

namespace public
{

template<class T>
class Z
{
}; //Z

template<class ABC>
class X
{
protected:
    template<class T>
    class Y: public Z<T>
    {
        void MyFunc( X<ABC>& base )
        {
            do somthing...;
        }
    }; //Y

    // Explicit specialization for "void" class.
    template<>
    class Y<void>: public Z<void>
    {
        void MyFunc( X<ABC>& base )
        {
            do somthing else...;
        }
    }; //Y explicit specialization

    template<typename T> friend class Y;
}; //X

} // public

The above explicit inner class declaration for "void" is giving errors...
Errors for the line after the code comment of Explicity specialization):
error: explicit specialization in non-namespace scope 'class public::X<ABC>'
error:     'ABC'
Error for line with friend class declaratoin:
error: too many template-parameter-lists

The written code was very old and it has been compiled under Linux in the
past. I'm wondering if an older version of GCC supported this, or whether it
is GCC supported extension that can be switched on to compile it
successfully. Did anyone has faced the similar issue? Could you please guide
me how can I resolve this? Is there any compiler option that still allows to
work this syntax?

Note that the C++ standard says you cannot specialise the inner template
without specialising the outer template. But I can not declare/define inner
template class Y outside as it is using the outer template class parameter
for the function.
-- 
View this message in context: http://old.nabble.com/Explicity-template-specialization-issue-tp32503712p32503712.html
Sent from the gcc - Help mailing list archive at Nabble.com.



[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