Aşağıdaki kod parçacığı MSVC ++ 2010'da derlenmeyecektir (gcc, icc ve sun CC ile iyi derler):
#include
template< class T, unsigned D > struct Attribute
{
T attr[D];
};
template< class T, unsigned D, class A = Attribute< T, D > > struct Point
{
T coor[D];
A a;
};
template< class P1, class P2 > struct Pair;
template< class T1, class T2, unsigned D > struct Pair< Point< T1, D>, Point< T2, D > >
{
Point< T1, D> p1;
Point< T2, D> p2;
static const char * id()
{
return "specialized";
}
};
int main()
{
Pair< Point< float, 3>, Point< double, 3> > p;
std::cout << p.id() << std::endl;
return 0;
}
If I remove a default for class A
from Point
declaration it compiles just fine. Any suggestions on how to work around this issue without changing non-specialized declaration of Pair (i.e., template< class P1, class P2 > struct Pair;
) are greatly appreciated. Removing defaults in the real code is not an option either.
error C2079: 'p' uses undefined struct 'Pair'
with
[
P1=Point,
P2=Point
]