I want to specialize a function template. This function is declared in a namespace:
namespace foo
{
template <int>
void function();
}
(For simplicity, the template is based on an int, whereas in my production code, it is an enum class, but it is the same issue. The same goes for a type based template)
Now I want to specialize it for a specific value:
template <>
void foo::function<0>()
{
}
This fails to compile with g++ -std=c++11 (versions 4.6, 4.7, 4.8 and 4.9):
specialization of ‘template void foo::function()’ in different namespace [-fpermissive]
clang++ -std=c++11 accepts this code.
g++ also accepts the following piece:
namespace foo
{
template <>
void function<0>()
{
}
}
Who's right, gcc or clang?
Aucun commentaire:
Enregistrer un commentaire