mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-06 08:46:49 +08:00
* improvements in compiler function detection.
This commit is contained in:
parent
c9d0ac0084
commit
843aa3f703
@ -7,14 +7,32 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Testing for https://wg21.link/N3652, adopted in C++14
|
// C++14 constexpr
|
||||||
#if defined(__cpp_constexpr) && __cpp_constexpr >= 201304
|
#if defined(__cpp_constexpr) && __cpp_constexpr >= 201304L
|
||||||
|
#define FASTFLOAT_CONSTEXPR14 constexpr
|
||||||
|
#elif __cplusplus >= 201402L
|
||||||
|
#define FASTFLOAT_CONSTEXPR14 constexpr
|
||||||
|
#elif defined(_MSC_VER) && _MSC_VER >= 1910 && _MSVC_LANG >= 201402L
|
||||||
#define FASTFLOAT_CONSTEXPR14 constexpr
|
#define FASTFLOAT_CONSTEXPR14 constexpr
|
||||||
#else
|
#else
|
||||||
#define FASTFLOAT_CONSTEXPR14
|
#define FASTFLOAT_CONSTEXPR14
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// C++14 variable templates
|
||||||
|
#if defined(__cpp_variable_templates) && __cpp_variable_templates >= 201304L
|
||||||
|
#define FASTFLOAT_HAS_VARIABLE_TEMPLATES 1
|
||||||
|
#elif __cplusplus >= 201402L
|
||||||
|
#define FASTFLOAT_HAS_VARIABLE_TEMPLATES 1
|
||||||
|
#elif defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190023918L && \
|
||||||
|
_MSVC_LANG >= 201402L
|
||||||
|
#define FASTFLOAT_HAS_VARIABLE_TEMPLATES 1
|
||||||
|
#else
|
||||||
|
#define FASTFLOAT_HAS_VARIABLE_TEMPLATES 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// C++20 std::bit_cast
|
||||||
#if defined(__cpp_lib_bit_cast) && __cpp_lib_bit_cast >= 201806L
|
#if defined(__cpp_lib_bit_cast) && __cpp_lib_bit_cast >= 201806L
|
||||||
|
#include <bit>
|
||||||
#define FASTFLOAT_HAS_BIT_CAST 1
|
#define FASTFLOAT_HAS_BIT_CAST 1
|
||||||
#else
|
#else
|
||||||
#define FASTFLOAT_HAS_BIT_CAST 0
|
#define FASTFLOAT_HAS_BIT_CAST 0
|
||||||
@ -35,12 +53,39 @@
|
|||||||
#define FASTFLOAT_HAS_BYTESWAP 0
|
#define FASTFLOAT_HAS_BYTESWAP 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// C++17 if constexpr
|
||||||
#if defined(__cpp_if_constexpr) && __cpp_if_constexpr >= 201606L
|
#if defined(__cpp_if_constexpr) && __cpp_if_constexpr >= 201606L
|
||||||
#define FASTFLOAT_IF_CONSTEXPR17(x) if constexpr (x)
|
#define FASTFLOAT_IF_CONSTEXPR17(x) if constexpr (x)
|
||||||
|
#elif defined(__cpp_constexpr) && __cpp_constexpr >= 201603L
|
||||||
|
#define FASTFLOAT_IF_CONSTEXPR17(x) if constexpr (x)
|
||||||
|
#elif __cplusplus >= 201703L
|
||||||
|
#define FASTFLOAT_IF_CONSTEXPR17(x) if constexpr (x)
|
||||||
|
#elif defined(_MSC_VER) && _MSC_VER >= 1911 && _MSVC_LANG >= 201703L
|
||||||
|
#define FASTFLOAT_IF_CONSTEXPR17(x) if constexpr (x)
|
||||||
#else
|
#else
|
||||||
#define FASTFLOAT_IF_CONSTEXPR17(x) if (x)
|
#define FASTFLOAT_IF_CONSTEXPR17(x) if (x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// C++17 inline variables
|
||||||
|
#if defined(__cpp_inline_variables) && __cpp_inline_variables >= 201606L
|
||||||
|
#define FASTFLOAT_INLINE_VARIABLE inline constexpr
|
||||||
|
#elif __cplusplus >= 201703L
|
||||||
|
#define FASTFLOAT_INLINE_VARIABLE inline constexpr
|
||||||
|
#elif defined(_MSC_VER) && _MSC_VER >= 1912 && _MSVC_LANG >= 201703L
|
||||||
|
#define FASTFLOAT_INLINE_VARIABLE inline constexpr
|
||||||
|
#else
|
||||||
|
#define FASTFLOAT_INLINE_VARIABLE static constexpr
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__cpp_lib_is_constant_evaluated) && \
|
||||||
|
__cpp_lib_is_constant_evaluated >= 201811L
|
||||||
|
#define FASTFLOAT_HAS_IS_CONSTANT_EVALUATED 1
|
||||||
|
#define FASTFLOAT_CONSTEVAL consteval
|
||||||
|
#else
|
||||||
|
#define FASTFLOAT_HAS_IS_CONSTANT_EVALUATED 0
|
||||||
|
#define FASTFLOAT_CONSTEVAL FASTFLOAT_CONSTEXPR14
|
||||||
|
#endif
|
||||||
|
|
||||||
// Testing for relevant C++20 constexpr library features
|
// Testing for relevant C++20 constexpr library features
|
||||||
#if FASTFLOAT_HAS_IS_CONSTANT_EVALUATED && FASTFLOAT_HAS_BIT_CAST && \
|
#if FASTFLOAT_HAS_IS_CONSTANT_EVALUATED && FASTFLOAT_HAS_BIT_CAST && \
|
||||||
defined(__cpp_lib_constexpr_algorithms) && \
|
defined(__cpp_lib_constexpr_algorithms) && \
|
||||||
@ -58,6 +103,12 @@
|
|||||||
#define FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE 1
|
#define FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__has_builtin)
|
||||||
|
#define FASTFLOAT_HAS_BUILTIN(x) __has_builtin(x)
|
||||||
|
#else
|
||||||
|
#define FASTFLOAT_HAS_BUILTIN(x) false
|
||||||
|
#endif
|
||||||
|
|
||||||
// For support attribute [[assume]] is declared in P1774
|
// For support attribute [[assume]] is declared in P1774
|
||||||
#if defined(__cpp_attrubute_assume)
|
#if defined(__cpp_attrubute_assume)
|
||||||
#define FASTFLOAT_ASSUME(expr) [[assume(expr)]]
|
#define FASTFLOAT_ASSUME(expr) [[assume(expr)]]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user