From d10980bc9f831d657a3aee1e4a85dc6fe8d7e861 Mon Sep 17 00:00:00 2001 From: MTahaK Date: Tue, 12 Dec 2023 18:46:38 -0500 Subject: [PATCH] Added conditions to include stdfloat, and new workflow for GCC 13 --- .github/workflows/ubuntu22-gcc13.yml | 23 +++++++++++++++++++++++ include/fast_float/parse_number.h | 16 ++++++++++------ 2 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/ubuntu22-gcc13.yml diff --git a/.github/workflows/ubuntu22-gcc13.yml b/.github/workflows/ubuntu22-gcc13.yml new file mode 100644 index 0000000..7757f8a --- /dev/null +++ b/.github/workflows/ubuntu22-gcc13.yml @@ -0,0 +1,23 @@ +name: Ubuntu 22.04 CI (GCC 13) + +on: [push, pull_request] + +jobs: + ubuntu-build: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + - name: Use cmake + run: | + mkdir build && + cd build && + CXX=g++-13 CXXFLAGS=-Werror cmake -DFASTFLOAT_TEST=ON .. && + cmake --build . && + ctest --output-on-failure + - name: Use cmake CXX20 + run: | + mkdir build20 && + cd build20 && + CXX=g++-13 CXXFLAGS=-Werror cmake -DFASTFLOAT_CONSTEXPR_TESTS=ON -DFASTFLOAT_CXX_STANDARD=20 -DFASTFLOAT_TEST=ON .. && + cmake --build . && + ctest --output-on-failure \ No newline at end of file diff --git a/include/fast_float/parse_number.h b/include/fast_float/parse_number.h index c65099b..656d0dd 100644 --- a/include/fast_float/parse_number.h +++ b/include/fast_float/parse_number.h @@ -10,7 +10,9 @@ #include #include #include -#include +#if __cplusplus >= 202300L || _MSVC_LANG >= 202300L + #include +#endif namespace fast_float { @@ -137,8 +139,9 @@ template FASTFLOAT_CONSTEXPR20 from_chars_result_t from_chars(UC const * first, UC const * last, T &value, chars_format fmt /*= chars_format::general*/) noexcept { -#ifdef __STDCPP_FLOAT32_T__ - // if std::float32_t is defined, then we are in C++23 mode; macro set for float32; +#if __cplusplus >= 202300L || _MSVC_LANG >= 202300L + #ifdef __STDCPP_FLOAT32_T__ + // if std::float32_t is defined, and we are in C++23 mode; macro set for float32; // set value to float due to equivalence between float and float32_t if(std::is_same::value){ float value32; @@ -146,9 +149,9 @@ from_chars_result_t from_chars(UC const * first, UC const * last, value = value32; return ret; } -#endif -#ifdef __STDCPP_FLOAT64_T__ - // if std::float64_t is defined, then we are in C++23 mode; macro set for float64; + #endif + #ifdef __STDCPP_FLOAT64_T__ + // if std::float64_t is defined, and we are in C++23 mode; macro set for float64; // set value as double due to equivalence between double and float64_t if(std::is_same::value){ double value64; @@ -156,6 +159,7 @@ from_chars_result_t from_chars(UC const * first, UC const * last, value = value64; return ret; } + #endif #endif return from_chars_advanced(first, last, value, parse_options_t{fmt}); }