From 574191ed36562a6083cae0c4a3b91aca5269aa7b Mon Sep 17 00:00:00 2001 From: Lau Ching Jun Date: Thu, 22 Jun 2023 12:33:44 -0700 Subject: [PATCH] Workaround a release blocker after libc++ change (flutter/engine#43091) The code breaks in C++20 mode after libc++ removes comparisons for `std::vector` and replaces them with 'operator <=>'. See cl/542541552 for context. --- .../client_wrapper/include/flutter/encodable_value.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/engine/src/flutter/shell/platform/common/client_wrapper/include/flutter/encodable_value.h b/engine/src/flutter/shell/platform/common/client_wrapper/include/flutter/encodable_value.h index 3b46f99f63..3a191205bb 100644 --- a/engine/src/flutter/shell/platform/common/client_wrapper/include/flutter/encodable_value.h +++ b/engine/src/flutter/shell/platform/common/client_wrapper/include/flutter/encodable_value.h @@ -215,6 +215,13 @@ class EncodableValue : public internal::EncodableValueVariant { } return std::get(*this); } + + // Explicitly provide operator<, delegating to std::variant's operator<. + // There are issues with with the way the standard library-provided + // < and <=> comparisons interact with classes derived from variant. + friend bool operator<(const EncodableValue& lhs, const EncodableValue& rhs) { + return static_cast(lhs) < static_cast(rhs); + } }; } // namespace flutter