I want to specialize a function template. This function is declared in the namespace:
namespace foo { template <int> void function(); }
(For simplicity, the template is int , whereas in my production code it is an enum class , but this is the same problem. The same goes for the type based template)
Now I want to specialize it for a specific value:
template <> void foo::function<0>() { }
This does not compile with g++ -std=c++11 (versions 4.6, 4.7, 4.8 and 4.9):
specialization "template void foo :: function () in different namespaces [-fpermissive]
clang++ -std=c++11 accepts this code.
g ++ also accepts the following snippet:
namespace foo { template <> void function<0>() { } }
Who is right, gcc or clang?
source share