<cut>\test.cpp:4:53: error: specialization of 'static void Test::Method() [with Test::Enum E = (Test::Enum)0]' after instantiation
template <> void Test::Method<Test::Enum::OPTION_1>() {
^
<cut>\test.cpp:8:53: error: specialization of 'static void Test::Method() [with Test::Enum E = (Test::Enum)1]' after instantiation
template <> void Test::Method<Test::Enum::OPTION_2>() {
^
<cut>\test.cpp:12:53: error: specialization of 'static void Test::Method() [with Test::Enum E = (Test::Enum)2]' after instantiation
template <> void Test::Method<Test::Enum::OPTION_3>() {
I've tried a lot of different ways of writing this. The only condition I have is to have the implementation of the specialized template methods to be in the source file.
I'd be glad if someone points me in the right direction :)
I think the problem is that the compiler needs to see that the template is specialized before it sees uses of the function. You could either forward-declare the specializations:
or move the definition of GetFunc() to the source, after the specializations. If you're going to use the specializations from other sources, you should forward-declare.