Question
Can auto be used for static class variable definition?
Consider this simple example:
struct Class {
struct Inner {};
static Inner a;
};
I cannot define this a
with this syntax:
auto Class::a = Inner{};
- gcc and msvc both complaint in a similar ways:
<source>:9:6: error: conflicting declaration 'auto Class::a'
9 | auto Class::a = Inner{};
| ^~~~~
<source>:6:18: note: previous declaration as 'Class::Inner Class::a'
6 | static Inner a;
| ^
but clang accepts this code.
Of course the reason for this syntax is to not repeat Class::
twice:
Class::Inner Class::a{};
So, the question - is it correct (clang is right) or incorrect (gcc and msvc are right)?