Consider the following code:
template <class x1, class x2 = int*>
struct CoreTemplate { };
template <class x1, class x2>
struct CoreTemplate<x1*, x2*> { int spec; CoreTemplate() { spec = 1; } };
template <class x>
struct CoreTemplate<x*> { int spec; CoreTemplate() { spec = 3; } };
int main(int argc, char* argv[])
{
CoreTemplate<int*, int*> qq1;
printf("var=%d.\r\n", qq1.spec);
CoreTemplate<int*> qq2;
printf("var=%d.\r\n", qq2.spec);
}
MSVC compiles this code fine and selects the second specialization in both cases. For me these specializations are identical. How legal is the second specialization in the first hand?
Just curious, any thoughts about this?