From 6d7f3ad1194f69fb961f4cbc3f65385d15aec65c Mon Sep 17 00:00:00 2001 From: Jesper Juhl Date: Tue, 19 May 2026 20:03:47 +0200 Subject: [PATCH] Don't check if defined(__cpp_if_constexpr) && (__cpp_if_constexpr >= 201606L) These checks are redundant as we now compile as C++17 and our minimum compilers all provide 'if constexpr'. So we can get rid of the fallback code. --- include/TGUI/Signal.hpp | 2 - include/TGUI/SignalManager.hpp | 68 ---------------------------------- 2 files changed, 70 deletions(-) diff --git a/include/TGUI/Signal.hpp b/include/TGUI/Signal.hpp index 50c687d52..8112c6358 100644 --- a/include/TGUI/Signal.hpp +++ b/include/TGUI/Signal.hpp @@ -125,11 +125,9 @@ namespace tgui unsigned int connect(const Func& func, const BoundArgs&... args) { const auto id = ++m_lastSignalId; -#if defined(__cpp_if_constexpr) && (__cpp_if_constexpr >= 201606L) if constexpr (sizeof...(BoundArgs) == 0) m_handlers[id] = func; else -#endif { m_handlers[id] = [=] { std::invoke(func, args...); }; } diff --git a/include/TGUI/SignalManager.hpp b/include/TGUI/SignalManager.hpp index 0a1f63754..49aa92b1a 100644 --- a/include/TGUI/SignalManager.hpp +++ b/include/TGUI/SignalManager.hpp @@ -93,7 +93,6 @@ namespace tgui //////////////////////////////////////////////////////////////////////////////////////////////////////////////// [[nodiscard]] static SignalManager::Ptr getSignalManager(); -#if defined(__cpp_if_constexpr) && (__cpp_if_constexpr >= 201606L) //////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// @brief Connects a signal handler that will be called when this signal is emitted /// @@ -107,41 +106,6 @@ namespace tgui template unsigned int connect(String widgetName, String signalName, Func&& handler, const BoundArgs&... args); -#else - //////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// @brief Connects a signal handler that will be called when this signal is emitted - /// - /// @param widgetName Name of the widget to connect to - /// @param signalName Name of the signal - /// @param handler Callback function that is given the extra arguments provided to this function as arguments - /// @param args Optional extra arguments to pass to the signal handler when the signal is emitted - /// - /// @return Unique id of the connection - //////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template >::value>* = nullptr> - unsigned int connect(String widgetName, String signalName, Func&& handler, const Args&... args); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// @brief Connects a signal handler that will be called when this signal is emitted - /// - /// @param widgetName Name of the widget to connect to - /// @param signalName Name of the signal - /// @param handler Callback function that is given a pointer to the widget, the name of the signal and the extra - /// arguments provided to this function as arguments - /// @param args Optional extra arguments to pass to the signal handler when the signal is emitted - /// - /// @return Unique id of the connection - //////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template >::value // Ambigious otherwise when passing bind expression - && std::is_convertible, const String&)>>::value>* = nullptr> - unsigned int connect(String widgetName, String signalName, Func&& handler, BoundArgs&&... args); -#endif - //////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// @brief Disconnect a signal handler /// @@ -209,7 +173,6 @@ namespace tgui //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#if defined(__cpp_if_constexpr) && (__cpp_if_constexpr >= 201606L) template unsigned int SignalManager::connect(String widgetName, String signalName, Func&& handler, const BoundArgs&... args) { @@ -232,37 +195,6 @@ namespace tgui connect(id); return id; } -#else - template >::value>*> - unsigned int SignalManager::connect(String widgetName, String signalName, Func&& handler, const Args&... args) - { - const unsigned int id = generateUniqueId(); - m_signals[id] = {widgetName, - signalName, - makeSignal([f = std::function(handler), args...]() { f(args...); })}; - - connect(id); - return id; - } - - template >::value // Ambigious otherwise when passing bind expression - && std::is_convertible, const String&)>>::value>*> - unsigned int SignalManager::connect(String widgetName, String signalName, Func&& handler, BoundArgs&&... args) - { - const unsigned int id = generateUniqueId(); - m_signals[id] = {widgetName, - signalName, - makeSignalEx( - [f = std::function&, const String&)>(handler), - args...](const std::shared_ptr& w, const String& s) { f(args..., w, s); })}; - - connect(id); - return id; - } -#endif } // namespace tgui #endif // TGUI_SIGNAL_MANAGER_HPP