AK: Fix rvalue Variant downcast to variant aliases
Pass the required TypeWrapper through the rvalue downcast<Variant<...>> path, matching the existing const& overload.
This commit is contained in:
parent
ae2783e705
commit
de4b665298
2 changed files with 6 additions and 1 deletions
|
|
@ -430,7 +430,7 @@ public:
|
|||
decltype(auto) downcast() &&
|
||||
{
|
||||
if constexpr (sizeof...(NewTs) == 1 && (IsSpecializationOf<NewTs, Variant> && ...)) {
|
||||
return move(*this).template downcast_variant<NewTs...>();
|
||||
return move(*this).downcast_variant(TypeWrapper<NewTs...> {});
|
||||
} else {
|
||||
Variant<NewTs...> instance { Variant<NewTs...>::invalid_index, Detail::VariantConstructTag {} };
|
||||
visit([&](auto& value) {
|
||||
|
|
|
|||
|
|
@ -132,6 +132,11 @@ TEST_CASE(as)
|
|||
EXPECT(one_integer_to_rule_them_all.has<i8>());
|
||||
EXPECT_EQ(fake_integer.get<i8>(), 60);
|
||||
EXPECT_EQ(one_integer_to_rule_them_all.get<i8>(), 60);
|
||||
|
||||
using OptionalFancyType = Variant<i8, i16, Empty>;
|
||||
auto definitely_fancy = OptionalFancyType { static_cast<i16>(12) }.downcast<SomeFancyType>();
|
||||
EXPECT(definitely_fancy.has<i16>());
|
||||
EXPECT_EQ(definitely_fancy.get<i16>(), 12);
|
||||
}
|
||||
|
||||
TEST_CASE(moved_from_state)
|
||||
|
|
|
|||
Loading…
Reference in a new issue