Reputation: 4839
The following compiles in Visual Studio 2015
template <int> struct Test;
template <> struct Test<0> {
template <int> static void foo();
template <> static void foo<0>() {}
template <> static void foo<1>() {}
};
But GCC 5.2 complains error: template-id 'foo<0>' in declaration of primary template template <> static void foo<0>() {}
How to fix the code so that it compiles in both compilers?
Upvotes: 1
Views: 70
Reputation: 3581
This should work in g++ and MSVC alike:
template <int>
struct Test;
template <>
struct Test<0>
{
template <int>
static void foo();
};
template <>
void Test<0>::foo<1>()
{
}
int main()
{
Test<0>::foo<1>();
}
Upvotes: 1
Reputation: 86
template<int> struct Test;
template<> struct Test<0> {
template<int> static void foo();
};
template<> void Test<0>::foo<0>() {}
template<> void Test<0>::foo<1>() {}
Try this
Upvotes: 3