Title
variant default constructor has vague constexpr requirements
Status
new
Section
[variant.ctor]
Submitter
Louis Dionne

Created on 2019-06-04.00:00:00, last changed 2019-07-23.15:26:26.

Messages

Date: 2019-07-23.15:26:26

Proposed resolution:

This wording is relative to N4810.

  1. Modify [variant.ctor] as indicated:

    constexpr variant() noexcept(see below);
    

    -2- Effects: […]

    -3- Ensures: […]

    -4- Throws: […]

    -5- Remarks: This function shall be usable in a context that requires constant evaluation if the alternative type T0 can be value-initialized in a context that requires constant evaluationconstexpr if and only if the value-initialization of the alternative type T0 would satisfy the requirements for a constexpr function. […]

Date: 2019-07-23.15:26:26

[ 2019-07 Issue Prioritiztion ]

Priority to 2 after discussion on the reflector.

Date: 2017-06-15.00:00:00

[ 2017-06-17, Tim Song comments ]

This issue is related to LWG 2833.

Date: 2019-06-04.00:00:00

In [variant.ctor] p5, we say:

Remarks: This function shall be constexpr if and only if the value-initialization of the alternative type T0 would satisfy the requirements for a constexpr function. […]

First of all, I find it confusing that we say "This function shall be constexpr if […]", when the declaration of the function clearly has the constexpr keyword on it unconditionally. Instead, I would use the wording "This function shall be usable in a constexpr context if […]".

Secondly, I think we shouldn't be using if-and-only-if since it restricts whether implementations can be constexpr-friendly as an extension. Instead, it seems better to just say "if".

Finally, I think the condition under which the function must be constexpr-friendly is not something we can test for because it says "value-initialization of the alternative type T0 would satisfy the requirements for a constexpr function", which doesn't imply the value initialization can actually be be performed inside a constexpr context (for example the default constructor could be constexpr friendly but not marked with the constexpr keyword).

History
Date User Action Args
2019-07-23 15:26:26adminsetmessages: + msg10497
2019-06-23 10:41:44adminsetmessages: + msg10454
2019-06-09 14:04:12adminsetmessages: + msg10429
2019-06-04 00:00:00admincreate