Skip to content

Commit 4e13ec1

Browse files
committed
check for HAS_CXX20_CONSTEXPR before attempting to do c++20 stuff
1 parent e5d5e57 commit 4e13ec1

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

include/fast_float/fast_float.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#if defined(__cpp_lib_bit_cast)
1313
#undef CXX20_CONSTEXPR
1414
#define CXX20_CONSTEXPR constexpr
15+
#define HAS_CXX20_CONSTEXPR 1
1516
#endif
1617
#endif
1718
#endif

include/fast_float/float_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
#if defined(__cpp_lib_bit_cast)
8282
#undef CXX20_CONSTEXPR
8383
#define CXX20_CONSTEXPR constexpr
84+
#define HAS_CXX20_CONSTEXPR 1
8485
#endif
8586
#endif
8687
#endif

tests/basictest.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include "fast_float/fast_float.h"
66
#include <iomanip>
77
#include <string>
8-
#include <version>
98

109
#ifndef SUPPLEMENTAL_TEST_DATA_DIR
1110
#define SUPPLEMENTAL_TEST_DATA_DIR "data/"
@@ -38,7 +37,7 @@
3837
#define FASTFLOAT_ODDPLATFORM 1
3938
#endif
4039

41-
#if defined(__cpp_lib_bit_cast)
40+
#if HAS_CXX20_CONSTEXPR
4241
#include <bit>
4342
#include <string_view>
4443
#endif
@@ -116,7 +115,7 @@ TEST_CASE("supplemental") {
116115
}
117116
#endif
118117

119-
#if defined(__cpp_lib_bit_cast)
118+
#if HAS_CXX20_CONSTEXPR
120119

121120
constexpr double tryParse(std::string_view input)
122121
{
@@ -136,7 +135,7 @@ static_assert(tryParse("3.14156") != 3.1415600000001);
136135
static_assert(std::isnan(tryParse("hellothere"))); // technically isnan is not constexpr but GCC and clang allow it
137136
#endif
138137

139-
#endif //#if defined(__cpp_lib_bit_cast)
138+
#endif //#if HAS_CXX20_CONSTEXPR
140139

141140
TEST_CASE("leading_zeroes") {
142141
constexpr const uint64_t bit = 1;

0 commit comments

Comments
 (0)