以下代码适用于Visual Studio 2008,但不适用于GCC/G ++ 4.3.4 20090804.根据C++标准,哪种行为是正确的?
template <int N>
struct A : A<N-1> {};
template <>
struct A<0> {};
struct B : A<1> {};
template <int N>
void Func(const A<N> &a) {}
int main()
{
A<1> a; //is derived from A<0>
Func(a); //vs2008: ok, g++: ok
//Comeau: ok
B b; //is derived from A<1>
Func(b); //vs2008: ok, g++: error, no matching function for call to Func(B&)
//Comeau: error: no instance of function template "Func" matches the
// argument list. The …Run Code Online (Sandbox Code Playgroud)