tint: Fix compilation on latest MSVC

Change-Id: Ia0ebf98e5dc0c05f65af1593bb62e6a6971785b7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124040
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Antonio Maiorano 2023-03-14 17:33:34 +00:00 committed by Dawn LUCI CQ
parent a2c7639a46
commit a370186824
1 changed files with 4 additions and 3 deletions

View File

@ -215,13 +215,14 @@ inline auto Switch(T* object, CASES&&... cases) {
auto try_case = [&](auto&& case_fn) {
using CaseFunc = std::decay_t<decltype(case_fn)>;
using CaseType = detail::SwitchCaseType<CaseFunc>;
bool success = false;
if constexpr (std::is_same_v<CaseType, Default>) {
if constexpr (kHasReturnType) {
new (result) ReturnType(static_cast<ReturnType>(case_fn(Default{})));
} else {
case_fn(Default{});
}
return true;
success = true;
} else {
if (type_info.Is<CaseType>()) {
auto* v = static_cast<CaseType*>(object);
@ -230,10 +231,10 @@ inline auto Switch(T* object, CASES&&... cases) {
} else {
case_fn(v);
}
return true;
success = true;
}
}
return false;
return success;
};
// Use a logical-or fold expression to try each of the cases in turn, until one matches the