diff --git a/include/ccmath/detail/compare/signbit.hpp b/include/ccmath/detail/compare/signbit.hpp index 55812da..53a104e 100644 --- a/include/ccmath/detail/compare/signbit.hpp +++ b/include/ccmath/detail/compare/signbit.hpp @@ -15,6 +15,14 @@ #include "ccmath/internal/type_traits/floating_point_traits.hpp" +// If we have C++23, we can use std::signbit as it is constexpr +#if (defined(__cpp_lib_constexpr_cmath) && __cpp_lib_constexpr_cmath >= 202202L) + #include + #ifndef CCMATH_HAS_CONSTEXPR_SIGNBIT + #define CCMATH_HAS_CONSTEXPR_SIGNBIT + #endif +#endif + // We only implement this for MSVC as that is the only manner to get constexpr signbit that is also static_assert-able #ifndef CCMATH_HAS_BUILTIN_BIT_CAST #if (defined(_MSC_VER) && _MSC_VER >= 1927) @@ -82,7 +90,9 @@ namespace ccm template ::value, int> = 0> [[nodiscard]] inline constexpr bool signbit(T x) noexcept { -#if defined(CCMATH_HAS_CONSTEXPR_BUILTIN_SIGNBIT) +#if defined(CCMATH_HAS_CONSTEXPR_SIGNBIT) + return std::signbit(x); +#elif defined(CCMATH_HAS_CONSTEXPR_BUILTIN_SIGNBIT) return __builtin_signbit(x); #elif defined(CCMATH_HAS_BUILTIN_BIT_CAST) // Check for the sign of +0.0 and -0.0 with __builtin_bit_cast diff --git a/include/ccmath/internal/helpers/fpclassify_helper.hpp b/include/ccmath/internal/helpers/fpclassify_helper.hpp index 3c7331c..f335bd4 100644 --- a/include/ccmath/internal/helpers/fpclassify_helper.hpp +++ b/include/ccmath/internal/helpers/fpclassify_helper.hpp @@ -51,11 +51,12 @@ namespace ccm::helpers eFP_ZERO, eFP_SUBNORMAL, eFP_NORMAL + // TODO: What the fuck? Why is this assertion being hit before the preprocessor has defined the compiler? static_assert(false, "FP_* macros are extremely implementation specific and are not defined for this compiler. Please add support for this compiler.") #endif }; } // Clean up the global namespace -#include "ccmath/internal/setup/compiler_undef.hpp" +//#include "ccmath/internal/setup/compiler_undef.hpp" diff --git a/include/ccmath/internal/setup/compiler_def.hpp b/include/ccmath/internal/setup/compiler_def.hpp index 9235d6d..84d235a 100644 --- a/include/ccmath/internal/setup/compiler_def.hpp +++ b/include/ccmath/internal/setup/compiler_def.hpp @@ -16,8 +16,6 @@ /// ATTENTION: If you add a new compiler remember to add it to compiler_undef.hpp also! -#pragma once - #if defined(__GNUC__) && !defined(CCMATH_COMPILER_GCC) #define CCMATH_COMPILER_GCC #define CCMATH_COMPILER_GCC_VER ((__GNUC__ * 10000) + (__GNUC_MINOR__ * 100) + __GNUC_PATCHLEVEL__) diff --git a/include/ccmath/internal/setup/compiler_undef.hpp b/include/ccmath/internal/setup/compiler_undef.hpp index f5b106e..c19c7df 100644 --- a/include/ccmath/internal/setup/compiler_undef.hpp +++ b/include/ccmath/internal/setup/compiler_undef.hpp @@ -6,8 +6,6 @@ * See LICENSE for more information. */ -#pragma once - // Undefine all the compiler macros to clean up the global namespace // GCC