Note: This paper was adopted into draft C++14 on Saturday at the Bristol UK ISO C++ meeting.
A new WG21 paper is available. A copy is linked below, and the paper will also appear in the next normal WG21 mailing. If you are not a committee member, please use the comments section below or the std-proposals forum for public discussion.
Document number: N3652
Date: 2013-04-18
Relaxing constraints on constexpr functions
by Richard Smith
This is a major extension to constexpr
. Excerpt:
This paper describes the subset of N3597 selected for inclusion in C++14, relaxing a number of restrictions on constexpr functions. These changes all received overwhelmingly strong or unopposed support under review of the Evolution Working Group. It also incorporates Option 2 of N3598.
The changes selected by the Evolution Working Group were:
- Allow declarations within
constexpr
functions, other than:
static
orthread_local
variables
uninitialized variables- Allow
if
andswitch
statements (but notgoto
)- Allow all looping statements:
for
(including range-basedfor
),while
, anddo-while
- Allow mutation of objects whose lifetime began within the constant expression evaluation.
In addition, in discussion of N3598, Option 2 was selected, which removes the rule that a
constexpr
non-static member function is implicitlyconst
.
Add a Comment
Comments are closed.