Title
Non-integral initialized static data members
Status
c++11
Section
11.4.9.3 [class.static.data]
Submitter
Jason Merrill

Created on 2010-08-02.00:00:00 last changed 122 months ago

Messages

Date: 2011-03-15.00:00:00

[Voted into the WP at the March, 2011 meeting as part of paper N3262.]

Date: 2010-11-15.00:00:00

Proposed resolution (November, 2010):

Change 11.4.9.3 [class.static.data] paragraph 3 as follows:

If a non-volatile const static data member is of const literal 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 (7.7 [expr.const]). A static data member of literal type can be declared in the class definition with the constexpr specifier...
Date: 2022-02-18.07:47:23

According to 11.4.9.3 [class.static.data] paragraph 3,

If a static data member is of const literal 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. A static data member of literal type can be declared in the class definition with the constexpr 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]

However, 7.7 [expr.const] bullet 2.7 allows only integral and enumeration types in constant expressions for the const case; the other types require constexpr to be considered constant expressions.

History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: fdis -> c++11
2011-04-10 00:00:00adminsetmessages: + msg3359
2011-04-10 00:00:00adminsetstatus: review -> fdis
2010-11-29 00:00:00adminsetmessages: + msg3097
2010-11-29 00:00:00adminsetstatus: open -> review
2010-08-02 00:00:00admincreate