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
constexprfunction if and only if all required element-wise initializations for copy and move, respectively, would satisfy the requirements for aconstexprfunction.
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 ofconstexprfunction if and only if all required element-wise initializations for copy and move, respectively, would satisfy the requirements for aconstexprfunctionpairshall 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 ofpairshall be a constant initializer for thatpairobject ( [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 oftupleshall be aconstexprfunction if and only if all required element-wise initializations for copy and move, respectively, would satisfy the requirements for aconstexprfunction. The defaulted move and copy constructor oftuple<>shall beconstexprfunctionstupleshall 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 oftupleshall be a constant initializer for thattupleobject ( [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 ofconstexprfunction if and only if the required initialization of the memberrep_for copy and move, respectively, would satisfy the requirements for aconstexprfunction.durationshall 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 ofdurationshall be a constant initializer for thatdurationobject ( [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: