variant
constructionSection: 22.6.3.2 [variant.ctor] Status: Resolved Submitter: Barry Revzin Opened: 2019-06-25 Last modified: 2020-11-09
Priority: 2
View other active issues in [variant.ctor].
View all other issues in [variant.ctor].
View all issues with Resolved status.
Discussion:
User mcencora on reddit today posted this example:
#include <variant> struct ConvertibleToBool { constexpr operator bool() const { return true; } }; static_assert(std::holds_alternative<bool>(std::variant<int, bool>(ConvertibleToBool{})));
Before P0608, the variant
holds bool
. After P0608,
the variant
holds int
so the static assertion fires.
bool
and (c)
hold int
is, but I think (a) and (b) are better options than (c).
[2019-07 Issue Prioritization]
Priority to 2 after discussion on the reflector.
[This is US212; status set to "LEWG" for guidance on desired behavior.]
[2020-05-28; LEWG issue reviewing]
P1957R2 was accepted in Prague as CWG motion 5 and resolves LWG 3228.
[2020-11-09 Resolved for C++20. Status changed: Tentatively Resolved → Resolved.]
Rationale:
Resolved by P1957R2.Proposed resolution: