Movatterモバイル変換


[0]ホーム

URL:


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

2025-12-20


1101. Non-integral initialized static data members

Section:11.4.9.3  [class.static.data]    Status:C++11    Submitter:Jason Merrill    Date:2010-08-02

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

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

If astatic data member is ofconstliteral type, its declaration in the class definition canspecify abrace-or-equal-initializer in which everyinitializer-clause that is anassignment-expression is a constant expression. Astatic data member of literal type can be declared in theclass definition with theconstexpr specifier; if so, itsdeclaration shall specify abrace-or-equal-initializer inwhich everyinitializer-clause that is anassignment-expression is a constant expression.[Note: In both these cases, the member may appear inconstant expressions. —end note]

However, 7.7 [expr.const] bullet 2.7allows only integral and enumeration types in constantexpressions for theconst case; the other typesrequireconstexpr to be considered constantexpressions.

Proposed resolution (November, 2010):

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

If anon-volatileconststatic datamember is ofconst literalintegral orenumeration type, its declaration in the class definition canspecify abrace-or-equal-initializer in which everyinitializer-clause that is anassignment-expression is aconstant expression(7.7 [expr.const]). Astatic data member of literal type can be declared in theclass definition with theconstexpr specifier...



[8]ページ先頭

©2009-2026 Movatter.jp