Yogesh Kini wrote:
Hi,
When I compile the below code using gcc 3.3 I get the errors as below.
But MS VC++ compiles it straight. Can any one please tell me what the problem is?
Thanks,
Yogesh
namespace xyz
{
template<class A, class B, class C>
class ABC
{
template<bool T>
struct M
{
float a,b,c;
};
template<>
struct M<true> -> Error here
{
int i,j,k;
};
};
};
This is ill-formed. For two reasons
1) [14.7.3]/2 says an explicit specialization of a member template shall
be declared in the namespace of the enclosing class. I.e. you
have to move the M<true> specialization out.
2) [14.7.3]/18 says that an explicit specialization of a member class template
of a templated class must also specialize the outer class. I.e. you
cannot put a specialized class inside a non-specialized class.
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@xxxxxxxxxxxxxxxx :: http://www.planetfall.pwp.blueyonder.co.uk