I have a template and a specialization defined like this:
template<typename T>
struct SomeTemplate final
{
};
template<>
struct SomeTemplate<int> final
{
};
int main()
{
SomeTemplate<int> test; // <-- error
}
Compiling with Visual C++ 2012 gives me the following error:
error C2913: explicit specialization; 'SomeTemplate<T>' is not a specialization of a class template
with
[
T=int
]
It compiles fine and does the right thing when I remove
- the
finalspecifiers - the
template<>from the specialization
The first case makes some sense to me, as it may very well be that final does also restrict specialization of templates (instead of only inheritance). The second case seems a bit strange to me, as I thought this should be a syntax error.
Is this behavior correct?