From 11d641bb97841af04b40f4368e88faabf1bb4d94 Mon Sep 17 00:00:00 2001 From: Roland Winklmeier Date: Thu, 23 Feb 2017 11:10:38 +0100 Subject: [PATCH] Fix error 'call of overloaded ... is ambiguous' With Qt 5.9, I got an error when calling compare(BlackMisc::Network::CEntityFlags::Entity, BlackMisc::Network::CEntityFlags::Entity). The underlying integral type of an enum is implementation defined and gcc seem to choose an unsigned int in this case. This made the call ambiguous, since there was no unsigned int overload yet of compare. --- src/blackmisc/comparefunctions.cpp | 6 ++++++ src/blackmisc/comparefunctions.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/blackmisc/comparefunctions.cpp b/src/blackmisc/comparefunctions.cpp index 7e5e81179..cd907371a 100644 --- a/src/blackmisc/comparefunctions.cpp +++ b/src/blackmisc/comparefunctions.cpp @@ -26,6 +26,12 @@ namespace BlackMisc return a < b ? -10 : 10; } + int compare(uint a, uint b) + { + if (a == b) return 0; + return a < b ? -10 : 10; + } + int compare(qint64 a, qint64 b) { if (a == b) return 0; diff --git a/src/blackmisc/comparefunctions.h b/src/blackmisc/comparefunctions.h index 5450334ce..b3a124485 100644 --- a/src/blackmisc/comparefunctions.h +++ b/src/blackmisc/comparefunctions.h @@ -26,6 +26,9 @@ namespace BlackMisc //! Compare int BLACKMISC_EXPORT int compare(int a, int b); + //! Compare uint + BLACKMISC_EXPORT int compare(uint a, uint b); + //! Compare qint64 BLACKMISC_EXPORT int compare(qint64 a, qint64 b);