From 57fbf5f681181d64df88e4721ef1aa612ce25ead Mon Sep 17 00:00:00 2001 From: ComixHe Date: Mon, 12 Aug 2024 12:05:55 +0800 Subject: [PATCH] fix: uninstantiated static_assert(false, "") was ill-formed This is c++ language core issue, refactoring the implementation of dumpDBusObject. core issue: https://cplusplus.github.io/CWG/issues/2518.html gcc has fixed this bug since version 13.1: relative-commit: https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=9944ca17c0766623bce260684edc614def7ea761 Signed-off-by: ComixHe --- src/global.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/global.h b/src/global.h index 1161602..865d599 100644 --- a/src/global.h +++ b/src/global.h @@ -544,6 +544,8 @@ template ObjectMap dumpDBusObject(const QHash> &map) { static_assert(std::is_base_of_v, "dumpDBusObject only support which derived by QObject class"); + static_assert(std::is_same_v || std::is_same_v, + "dumpDBusObject only support QString/QDBusObject as key type"); ObjectMap objs; for (const auto &[key, value] : map.asKeyValueRange()) { @@ -552,8 +554,6 @@ ObjectMap dumpDBusObject(const QHash> &map) objs.insert(QDBusObjectPath{getObjectPathFromAppId(key)}, interAndProps); } else if constexpr (std::is_same_v) { objs.insert(key, interAndProps); - } else { - static_assert(false, "dumpDBusObject only support QString/QDBusObject as key type"); } }