Thank you for letting me know! See patch below and hopefully attached.

Jøger

From 846b0e09a9b48396eabe86a688d56e85906fe212 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B8ger=20Hanseg=C3=A5rd?= mailto:joger.hanseg...@qt.io
Date: Thu, 27 Feb 2025 17:12:09 +0100
Subject: [PATCH] Add missing comparison operators for Microsoft::WRL::ComPtr

The current MinGW implementation of Microsoft::WRL::ComPtr does not have
comparison operators. Attempting to compare two ComPtr instances will
implicitly convert the ComPtr to bool, and comparison is performed
against the resulting two bool values. This means that any two non-null
ComPtr instances compare equal.

This patch fixes this issue by adding the missing comparison operators.
---
 mingw-w64-headers/include/wrl/client.h | 45 ++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/mingw-w64-headers/include/wrl/client.h 
b/mingw-w64-headers/include/wrl/client.h
index aeb886ea8..7d54bcf1c 100644
--- a/mingw-w64-headers/include/wrl/client.h
+++ b/mingw-w64-headers/include/wrl/client.h
@@ -263,6 +263,51 @@ namespace Microsoft {
                 return tmp->Release();
             }
         };
+
+        template <class T, class U>
+        bool operator==(const ComPtr<T> &a, const ComPtr<U> &b) throw()
+        {
+            static_assert(__is_base_of(T, U) || __is_base_of(U, T));
+            return a.Get() == b.Get();
+        }
+
+        template <class T>
+        bool operator==(const ComPtr<T> &a, std::nullptr_t) throw()
+        {
+            return a.Get() == nullptr;
+        }
+
+        template <class T>
+        bool operator==(std::nullptr_t, const ComPtr<T> &a) throw()
+        {
+            return a.Get() == nullptr;
+        }
+
+        template <class T, class U>
+        bool operator!=(const ComPtr<T> &a, const ComPtr<U> &b) throw()
+        {
+            static_assert(__is_base_of(T, U) || __is_base_of(U, T));
+            return a.Get() != b.Get();
+        }
+
+        template <class T>
+        bool operator!=(const ComPtr<T> &a, std::nullptr_t) throw()
+        {
+            return a.Get() != nullptr;
+        }
+
+        template <class T>
+        bool operator!=(std::nullptr_t, const ComPtr<T> &a) throw()
+        {
+            return a.Get() != nullptr;
+        }
+
+        template <class T, class U>
+        bool operator<(const ComPtr<T> &a, const ComPtr<U> &b) throw()
+        {
+            static_assert(__is_base_of(T, U) || __is_base_of(U, T));
+            return a.Get() < b.Get();
+        }
     }
 }

--
2.44.0.windows.1


From: Zach Bacon <wowzama...@gmail.com>
Sent: Thursday, February 27, 2025 7:11 PM
To: mingw-w64-public@lists.sourceforge.net
Cc: Jøger Hansegård <joger.hanseg...@qt.io>
Subject: Re: [Mingw-w64-public] [PATCH] Add missing comparison operators for 
Microsoft::WRL::ComPtr


You don't often get email from mailto:wowzama...@gmail.com. 
https://aka.ms/LearnAboutSenderIdentification

You forgot to attach the patch

On Thu, Feb 27, 2025, 12:53 p.m. Jøger Hansegård via Mingw-w64-public 
<mailto:mingw-w64-public@lists.sourceforge.net> wrote:
The current MinGW implementation of Microsoft::WRL::ComPtr does not have
comparison operators. Attempting to compare two ComPtr instances will
implicitly convert the ComPtr to bool, and comparison is performed
against the resulting two bool values. This means that any two non-null
ComPtr instances compare equal.

This patch fixes this issue by adding the missing comparison operators.

Kind regards,
Jøger Hansegård

_______________________________________________
Mingw-w64-public mailing list
mailto:Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
From 846b0e09a9b48396eabe86a688d56e85906fe212 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B8ger=20Hanseg=C3=A5rd?= <joger.hanseg...@qt.io>
Date: Thu, 27 Feb 2025 17:12:09 +0100
Subject: [PATCH] Add missing comparison operators for Microsoft::WRL::ComPtr

The current MinGW implementation of Microsoft::WRL::ComPtr does not have
comparison operators. Attempting to compare two ComPtr instances will
implicitly convert the ComPtr to bool, and comparison is performed
against the resulting two bool values. This means that any two non-null
ComPtr instances compare equal.

This patch fixes this issue by adding the missing comparison operators.
---
 mingw-w64-headers/include/wrl/client.h | 45 ++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/mingw-w64-headers/include/wrl/client.h 
b/mingw-w64-headers/include/wrl/client.h
index aeb886ea8..7d54bcf1c 100644
--- a/mingw-w64-headers/include/wrl/client.h
+++ b/mingw-w64-headers/include/wrl/client.h
@@ -263,6 +263,51 @@ namespace Microsoft {
                 return tmp->Release();
             }
         };
+
+        template <class T, class U>
+        bool operator==(const ComPtr<T> &a, const ComPtr<U> &b) throw()
+        {
+            static_assert(__is_base_of(T, U) || __is_base_of(U, T));
+            return a.Get() == b.Get();
+        }
+
+        template <class T>
+        bool operator==(const ComPtr<T> &a, std::nullptr_t) throw()
+        {
+            return a.Get() == nullptr;
+        }
+
+        template <class T>
+        bool operator==(std::nullptr_t, const ComPtr<T> &a) throw()
+        {
+            return a.Get() == nullptr;
+        }
+
+        template <class T, class U>
+        bool operator!=(const ComPtr<T> &a, const ComPtr<U> &b) throw()
+        {
+            static_assert(__is_base_of(T, U) || __is_base_of(U, T));
+            return a.Get() != b.Get();
+        }
+
+        template <class T>
+        bool operator!=(const ComPtr<T> &a, std::nullptr_t) throw()
+        {
+            return a.Get() != nullptr;
+        }
+
+        template <class T>
+        bool operator!=(std::nullptr_t, const ComPtr<T> &a) throw()
+        {
+            return a.Get() != nullptr;
+        }
+
+        template <class T, class U>
+        bool operator<(const ComPtr<T> &a, const ComPtr<U> &b) throw()
+        {
+            static_assert(__is_base_of(T, U) || __is_base_of(U, T));
+            return a.Get() < b.Get();
+        }
     }
 }
 
-- 
2.44.0.windows.1

_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to