[pairs.pair, variant.ctor, tuple.cnstr] Only functions can be "constexpr-suitable"#8807
[pairs.pair, variant.ctor, tuple.cnstr] Only functions can be "constexpr-suitable"#8807Quuxplusone wants to merge 1 commit intocplusplus:mainfrom
Conversation
…xpr-suitable" This starts by reverting commit 79aef51, and then un-teletypes the word `constexpr` in "is a `constexpr` function" in the last place it's currently teletyped (after cplusplus#6620, that is).
|
Isn't this another case of LWG2833? Once again, completely removing this kind of "this is usable in constexpr when ..." wording because it's not perfect will get an over my dead body objection. We should fix it, not remove it. Until it's fixed, it's better to keep it. |
@jwakely: Did you read the patch, though? It doesn't feel like you read the patch. |
|
I didn't, sorry, I had a kneejerk reaction to "strike the Remarks" and flipped the table. This doesn't feel editorial, but then neither was using the new term here, I guess. Reopening. |
[variant.ctor]/6 currently has—
First glance:
constexprshould not be in teletype font. We don't mean that this constructor isconstexpr; we mean that this constructor is a constexpr function ([dcl.constexpr]/2).Second glance: The only way for a function to be anything but constexpr-suitable is for it to be a coroutine. I don't think the value-initialization of
T_0can be a coroutine. Therefore the whole "if and only if" predicate can be eliminated. Which leaves only "This function is constexpr," which is obvious from the declaration (in that it uses theconstexprkeyword).Third glance: Actually it is a category error to talk about an "initialization" being "constexpr-suitable." A function (i.e. an entity) can be constexpr-suitable; it is not meaningful to talk about an initialization (nor an expression) being constexpr-suitable. So even if the sentence weren't redundant it would still fail to "type-check."
My initial suggestion: The function is already declared
constexpr. Strike the Remarks.However, looking at the history, it looks like this wording got into its current state as a result of commit 79aef519 — which was just wrong — but the previous wording was clearly there to deal with the longstanding open question of how LWG is supposed to specify that a particular function call is "constexpr-friendly." We want to mandate that
std::variant<std::string> v;must be constexpr-friendly, whilestd::variant<std::regex> v;is not (as of C++26) constexpr-friendly. To completely strike these sentences would probably be worse than the status quo, in that department.Therefore this proposed change starts by merely reverting commit 79aef51 to get rid of the incorrect use of "constexpr-suitable," and then additionally un-teletypes the word
constexprin "is aconstexprfunction." (That was the last place it's teletyped anymore, after #6620.)