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 <heyuming@deepin.org>
This commit is contained in:
ComixHe 2024-08-12 12:05:55 +08:00 committed by HarryLoong
parent 7939cd568a
commit 57fbf5f681

View File

@ -544,6 +544,8 @@ template <typename Key, typename Value>
ObjectMap dumpDBusObject(const QHash<Key, QSharedPointer<Value>> &map) ObjectMap dumpDBusObject(const QHash<Key, QSharedPointer<Value>> &map)
{ {
static_assert(std::is_base_of_v<QObject, Value>, "dumpDBusObject only support which derived by QObject class"); static_assert(std::is_base_of_v<QObject, Value>, "dumpDBusObject only support which derived by QObject class");
static_assert(std::is_same_v<Key, QString> || std::is_same_v<Key, QDBusObjectPath>,
"dumpDBusObject only support QString/QDBusObject as key type");
ObjectMap objs; ObjectMap objs;
for (const auto &[key, value] : map.asKeyValueRange()) { for (const auto &[key, value] : map.asKeyValueRange()) {
@ -552,8 +554,6 @@ ObjectMap dumpDBusObject(const QHash<Key, QSharedPointer<Value>> &map)
objs.insert(QDBusObjectPath{getObjectPathFromAppId(key)}, interAndProps); objs.insert(QDBusObjectPath{getObjectPathFromAppId(key)}, interAndProps);
} else if constexpr (std::is_same_v<Key, QDBusObjectPath>) { } else if constexpr (std::is_same_v<Key, QDBusObjectPath>) {
objs.insert(key, interAndProps); objs.insert(key, interAndProps);
} else {
static_assert(false, "dumpDBusObject only support QString/QDBusObject as key type");
} }
} }