From 0e2e1bf8d0fb1662f51678ac1e9346ff21f33a21 Mon Sep 17 00:00:00 2001 From: sha512sum Date: Sun, 7 Jul 2024 22:59:15 +0000 Subject: [PATCH] Use custom IsConstant instead __builtin_constant_p --- include/cserver/engine/components.hpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/include/cserver/engine/components.hpp b/include/cserver/engine/components.hpp index 3592ac7..ae6ff39 100644 --- a/include/cserver/engine/components.hpp +++ b/include/cserver/engine/components.hpp @@ -334,9 +334,26 @@ namespace impl { template struct DependencyInfoKey {}; +template +consteval auto IsConstantImpl(...) { + return false; +}; + +template +consteval auto IsConstantImpl(bool) { + return true; +}; + +template +consteval auto IsConstant() -> bool { + return IsConstantImpl(true); // NOLINT +}; + template inline constexpr auto Use() { - std::ignore = __builtin_constant_p(T{Args...}); + std::ignore = IsConstant<[] { + T{Args...}; + }>(); }; template