Use custom IsConstant instead __builtin_constant_p

This commit is contained in:
sha512sum 2024-07-07 22:59:15 +00:00
parent cfb5f82948
commit 0e2e1bf8d0

View file

@ -334,9 +334,26 @@ namespace impl {
template <typename Current, std::size_t I>
struct DependencyInfoKey {};
template <auto F>
consteval auto IsConstantImpl(...) {
return false;
};
template <auto F, auto = (F(), 1)>
consteval auto IsConstantImpl(bool) {
return true;
};
template <auto F>
consteval auto IsConstant() -> bool {
return IsConstantImpl<F>(true); // NOLINT
};
template <typename T, auto... Args>
inline constexpr auto Use() {
std::ignore = __builtin_constant_p(T{Args...});
std::ignore = IsConstant<[] {
T{Args...};
}>();
};
template <typename...>