Anyone can tell me g++ can NOT compile the simple program with error:
test.cpp:12: error: invalid explicit specialization before '>' token
test.cpp:12: error: explicit specialization in non-namespace scope
`class C'
test.cpp:14: error: invalid member function declaration
But MSVC++ can.
Thanks
rbfish
#include "stdio.h"
class C
{
public:
template<int N>
void f()
{
printf("f<N=%d> ()\n", N);
}
template<>
void f<1>()
{
printf("f<1>()\ n");
}
};
int main()
{
C c;
c.f<1>();
c.f<2>();
return 0;
}
test.cpp:12: error: invalid explicit specialization before '>' token
test.cpp:12: error: explicit specialization in non-namespace scope
`class C'
test.cpp:14: error: invalid member function declaration
But MSVC++ can.
Thanks
rbfish
#include "stdio.h"
class C
{
public:
template<int N>
void f()
{
printf("f<N=%d> ()\n", N);
}
template<>
void f<1>()
{
printf("f<1>()\ n");
}
};
int main()
{
C c;
c.f<1>();
c.f<2>();
return 0;
}
Comment