From 88a6c8c9050f0f65a16f3e0e532472725070e8fd Mon Sep 17 00:00:00 2001 From: PB Date: Mon, 13 Jul 2020 23:53:50 +0200 Subject: [PATCH] Fix building wxMSW using GCC 10.1 with C++20 standard Add comparison operator overloads using NativeFormat to wxDataFormat to prevent ambiguous operator overload errors. Closes https://github.com/wxWidgets/wxWidgets/pull/1962 --- include/wx/msw/ole/dataform.h | 2 ++ src/msw/ole/dataobj.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/wx/msw/ole/dataform.h b/include/wx/msw/ole/dataform.h index 77ebf70e4d..b86ac09bb3 100644 --- a/include/wx/msw/ole/dataform.h +++ b/include/wx/msw/ole/dataform.h @@ -41,6 +41,8 @@ public: bool operator!=(wxDataFormatId format) const; bool operator==(const wxDataFormat& format) const; bool operator!=(const wxDataFormat& format) const; + bool operator==(NativeFormat format) const; + bool operator!=(NativeFormat format) const; // explicit and implicit conversions to NativeFormat which is one of // standard data types (implicit conversion is useful for preserving the diff --git a/src/msw/ole/dataobj.cpp b/src/msw/ole/dataobj.cpp index d03d4277c6..e584ced903 100644 --- a/src/msw/ole/dataobj.cpp +++ b/src/msw/ole/dataobj.cpp @@ -369,6 +369,16 @@ bool wxDataFormat::operator!=(const wxDataFormat& format) const return !(*this == format); } +bool wxDataFormat::operator==(NativeFormat format) const +{ + return HtmlFormatFixup(*this).m_format == format; +} + +bool wxDataFormat::operator!=(NativeFormat format) const +{ + return !(*this == format); +} + void wxDataFormat::SetId(const wxString& format) { m_format = (wxDataFormat::NativeFormat)::RegisterClipboardFormat(format.t_str());