diff --git a/src/corelib/global/qttypetraits.h b/src/corelib/global/qttypetraits.h index e8939e7d5f..7e991ab8ca 100644 --- a/src/corelib/global/qttypetraits.h +++ b/src/corelib/global/qttypetraits.h @@ -45,6 +45,13 @@ noexcept(std::conjunction_v, return old; } +namespace QtPrivate { +// helper to be used to trigger a "dependent static_assert(false)" +// (for instance, in a final `else` branch of a `if constexpr`.) +template struct type_dependent_false : std::false_type {}; +template struct value_dependent_false : std::false_type {}; +} + QT_END_NAMESPACE #endif // QTTYPETRAITS_H diff --git a/src/corelib/tools/qflatmap_p.h b/src/corelib/tools/qflatmap_p.h index 6937d21544..68ab567439 100644 --- a/src/corelib/tools/qflatmap_p.h +++ b/src/corelib/tools/qflatmap_p.h @@ -848,7 +848,6 @@ public: size_type remove_if(Predicate pred) { const auto indirect_call_to_pred = [pred = std::move(pred)](iterator it) { - [[maybe_unused]] auto dependent_false = [](auto &&...) { return false; }; using Pair = decltype(*it); using K = decltype(it.key()); using V = decltype(it.value()); @@ -860,7 +859,7 @@ public: } else if constexpr (std::is_invocable_v && !std::is_invocable_v) { return pred(it.key()); } else { - static_assert(dependent_false(pred), + static_assert(QtPrivate::type_dependent_false(), "Don't know how to call the predicate.\n" "Options:\n" "- pred(*it)\n"