Reputation: 77
Following code can be compiled with MSVC 14.1 but not with Clang 5.0.1.
template <typename T>
class C
{
public:
static int a[];
};
int C<int>::a[1] = { 1 };
Clang's error message is:
error: template specialization requires 'template<>'
Is this code compliant with C++ standard? I found related passage in here as follows.
When defining a member of an explicitly specialized class template outside the body of the class, the syntax template <> is not used
Upvotes: 2
Views: 162
Reputation: 96233
This isn't an explicitly specialized class template
(that would be if you had for example a fully-specialized C<Foo>
) so that passage doesn't apply to your code here. You do in fact need template<>
for this.
Upvotes: 1