This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Open status.
constexpr
guarantees of defaulted functions still insufficientSection: 22.3.2 [pairs.pair], 22.4.4.2 [tuple.cnstr], 30.5 [time.duration] Status: Open Submitter: Daniel Krügler Opened: 2013-09-09 Last modified: 2020-06-13
Priority: 3
View other active issues in [pairs.pair].
View all other issues in [pairs.pair].
View all issues with Open status.
Discussion:
During the acceptance of N3471 and
some similar constexpr
papers, specific wording was added to pair
, tuple
, and other templates
that were intended to impose implementation constraints that ensure that the observable constexpr
"character"
of a defaulted function template is solely determined by the required expressions of the user-provided types when instantiated,
for example:
The defaulted move and copy constructor, respectively, of pair shall be a
constexpr
function if and only if all required element-wise initializations for copy and move, respectively, would satisfy the requirements for aconstexpr
function.
This wording doesn't require enough, especially since the core language via CWG 1358 does now support constexpr
function template instantiations, even if such function cannot appear in a constant expression (as specified in 7.7 [expr.const])
or as a constant initializer of that object (as specified in [basic.start.init]). The wording should be
improved and should require valid uses in constant expressions and as constant initializers instead.
[Lenexa 2015-05-05]
STL : notice order of move/copy and copy/move with "respectively".
General word-smithing; ask for updated wording
Are we happy with this with changes we are suggesting?
unanimous
[2016-12-14, Daniel comments]
LWG 2833(i) overlaps considerably and both should be resolved together.
Previous resolution from Daniel [SUPERSEDED]:This wording is relative to N3691.
Change 22.3.2 [pairs.pair] p2 as indicated:
-2-
The defaulted move and copy constructor, respectively, of pair shall be aAn invocation of the move or copy constructor ofconstexpr
function if and only if all required element-wise initializations for copy and move, respectively, would satisfy the requirements for aconstexpr
functionpair
shall be a constant expression (7.7 [expr.const]) if all required element-wise initializations would be constant expressions. An invocation of the move or copy constructor ofpair
shall be a constant initializer for thatpair
object ( [basic.start.init]) if all required element-wise initializations would be constant initializers for the respective subobjects.Change 22.4.4.2 [tuple.cnstr] p2 as indicated:
-2-
The defaulted move and copy constructor, respectively, ofAn invocation of the move or copy constructor oftuple
shall be aconstexpr
function if and only if all required element-wise initializations for copy and move, respectively, would satisfy the requirements for aconstexpr
function. The defaulted move and copy constructor oftuple<>
shall beconstexpr
functionstuple
shall be a constant expression (7.7 [expr.const]) if all required element-wise initializations would be constant expressions. An invocation of the move or copy constructor oftuple
shall be a constant initializer for thattuple
object ( [basic.start.init]) if all required element-wise initializations would be constant initializers for the respective subobjects. An invocation of the move or copy constructor oftuple<>
shall be a constant expression, or a constant initializer for thattuple<>
object, respectively, if the function argument would be constant expression.Change 30.5 [time.duration] p7 as indicated:
-7- Remarks:
The defaulted copy constructor of duration shall be aAn invocation of the copy constructor ofconstexpr
function if and only if the required initialization of the memberrep_
for copy and move, respectively, would satisfy the requirements for aconstexpr
function.duration
shall be a constant expression (7.7 [expr.const]) if the required initialization of the memberrep_
would be a constant expression. An invocation of the copy constructor ofduration
shall be a constant initializer for thatduration
object ( [basic.start.init]) if the required initialization of the memberrep_
would be constant initializers for this subobject.
[2020-06-08 Nina Dinka Ranns comments]
The revised wording provided by LWG 2833(i) should resolve this issue as well.
Proposed resolution: