In C++03, we had the ability to initialize const
static
class data members inline within the class definition, but still had to define the member i
[C++11: 9.4.2/3]:
If a non-volatileconst
static
data member is of integral or enumeration type, its declaration in the class definition can specify a brace-or-equal-initializer in which every initializer-clause that is an assignment-expression is a constant expression (5.19). Astatic
data member of literal type can be declared in the class definition with theconstexpr
specifier; if so, its declaration shall specify a brace-or-equal-initializer in which every initializer-clause that is an assignment-expression is a constant expression. [ Note: In both these cases, the member may appear in constant expressions. —end note ] The member shall still be defined in a namespace scope if it is odr-used (3.2) in the program and the namespace scope definition shall not contain an initializer.
This is comparable to the wording in C++03:
[C++03: 9.4.2/2]:
If a static data member is ofconst
integral orconst
enumeration type, its declaration in the class definition can specify a constant-initializer which shall be an integral constant expression (5.19). In that case, the member can appear in integral constant expressions. The member shall still be defined in a namespace scope if it is used in the program and the namespace scope definition shall not contain an initializer.
As you can see, the rule itself hasn't changed at all, beyond the introduction of rules for constexpr
.