Title
In-class initialized members must be const
Status
tc1
Section
12.2 [class.mem]
Submitter
John Wiegley

Created on 1998-12-29.00:00:00 last changed 208 months ago

Messages

Date: 1999-04-15.00:00:00

Proposed Resolution (10/99): Change the sentence in 12.2 [class.mem] paragraph 4 to read:

A member-declarator can contain a constant-initializer only if it declares a static member (12.2.3 [class.static] ) of const integral or const enumeration type, see 12.2.3.2 [class.static.data] .
Date: 2004-09-10.00:00:00

The standard says, in 12.2 [class.mem] paragraph 4:

A member-declarator can contain a constant-initializer only if it declares a static member (12.2.3 [class.static] ) of integral or enumeration type, see 12.2.3.2 [class.static.data] .
But later, in the section on static class data member initialization, 12.2.3.2 [class.static.data] paragraph 4, it says:
If a static data member is of const integral or const enumeration type, its declaration in the class definition can specify a constant-initializer which shall be an integral constant expression (8.20 [expr.const] ). In that case, the member can appear in integral constant expressions within its scope.
The first paragraph should be modified to make it clear that it is not possible to initialize a static data member in-line with a constant-initializer if that data member is of integral (or enumeration) type, and yet not const.
History
Date User Action Args
2003-04-25 00:00:00adminsetstatus: dr -> tc1
2000-02-23 00:00:00adminsetstatus: ready -> dr
1999-09-14 00:00:00adminsetmessages: + msg83
1998-12-29 00:00:00admincreate