template enclosing in 4.1.0

Ilja Golshtein ilejn@yandex.ru
Wed Mar 29 15:15:00 GMT 2006


Hello!

I enclose with this letter a very simple piece of code
I failed to compile by 4.1.0 while I have no troublles with 
older releases.

[class.mfct] says: A member function definition that appears outside of the class definition
shall appear in a namespace scope enclosing the class definition.

In my example B encloses class definition because of using directive,
doesn't it? What is the reason 4.1.0 reports an error? 

Any ideas how the code below could be compiled by 4.1.0 are highly appreciated.

Thanks.


[ilejn@pingvin tmp]$ cat aaa.cpp
namespace A
{
    template <typename T>
    class CL
    {
	T t;
    };
}

namespace B
{
    using namespace A;
}

namespace B
{
    template class CL<int>;
}

int main()
{
}
[ilejn@pingvin tmp]$ ~/gcc410/bin/g++ --version
g++ (GCC) 4.1.0
...
[ilejn@pingvin tmp]$ ~/gcc410/bin/g++ aaa.cpp
aaa.cpp:17: error: explicit instantiation of б▒class A::CL<int>б▓ in namespace б▒Bб▓ (which does not enclose namespace б▒Aб▓)
[ilejn@pingvin tmp]$ /usr/bin/g++ --version
g++ (GCC) 4.0.0 20050519 (Red Hat 4.0.0-8)
...
[ilejn@pingvin tmp]$ /usr/bin/g++ aaa.cpp
[ilejn@pingvin tmp]$


-- 
Best regards
Ilja Golshtein



More information about the Gcc-help mailing list