This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-11-11


902. In-class initialization of non-constant static data members

Section: 11.4.9.3  [class.static.data]     Status: NAD     Submitter: Daniel Krügler     Date: 21 May, 2009

The current wording of 11.4.9.3 [class.static.data] only allows a static data member to be initialized within the class definition if it is const. This restriction should be removed.

Rationale (July, 2009):

The consensus of the CWG was that there is insufficient motivation for such a change. A non-const static data member must still be defined outside the class if it is used, and the value of such a member cannot be used in a constant expression, unlike a constant static data member, so there is no real advantage to putting the initializer inside the class definition instead of in the definition of the static data member. The apparent parallel with non-static data member initialization is also not compelling; for example, the initializer for a non-static data member can contain forward references to members declared later in the class, while the same is not true of static data member initializers.