check for HAS_CXX20_CONSTEXPR before attempting to do c++20 stuff

This commit is contained in:
Jonas Rahlf 2021-09-02 23:20:28 +02:00
parent e5d5e576a6
commit 4e13ec151b
3 changed files with 5 additions and 4 deletions

View File

@ -12,6 +12,7 @@
#if defined(__cpp_lib_bit_cast)
#undef CXX20_CONSTEXPR
#define CXX20_CONSTEXPR constexpr
#define HAS_CXX20_CONSTEXPR 1
#endif
#endif
#endif

View File

@ -81,6 +81,7 @@
#if defined(__cpp_lib_bit_cast)
#undef CXX20_CONSTEXPR
#define CXX20_CONSTEXPR constexpr
#define HAS_CXX20_CONSTEXPR 1
#endif
#endif
#endif

View File

@ -5,7 +5,6 @@
#include "fast_float/fast_float.h"
#include <iomanip>
#include <string>
#include <version>
#ifndef SUPPLEMENTAL_TEST_DATA_DIR
#define SUPPLEMENTAL_TEST_DATA_DIR "data/"
@ -38,7 +37,7 @@
#define FASTFLOAT_ODDPLATFORM 1
#endif
#if defined(__cpp_lib_bit_cast)
#if HAS_CXX20_CONSTEXPR
#include <bit>
#include <string_view>
#endif
@ -116,7 +115,7 @@ TEST_CASE("supplemental") {
}
#endif
#if defined(__cpp_lib_bit_cast)
#if HAS_CXX20_CONSTEXPR
constexpr double tryParse(std::string_view input)
{
@ -136,7 +135,7 @@ static_assert(tryParse("3.14156") != 3.1415600000001);
static_assert(std::isnan(tryParse("hellothere"))); // technically isnan is not constexpr but GCC and clang allow it
#endif
#endif //#if defined(__cpp_lib_bit_cast)
#endif //#if HAS_CXX20_CONSTEXPR
TEST_CASE("leading_zeroes") {
constexpr const uint64_t bit = 1;