mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-06 16:56:57 +08:00
Added conditions to include stdfloat, and new workflow for GCC 13
This commit is contained in:
parent
62a4129a1c
commit
d10980bc9f
23
.github/workflows/ubuntu22-gcc13.yml
vendored
Normal file
23
.github/workflows/ubuntu22-gcc13.yml
vendored
Normal file
@ -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
|
||||
@ -10,7 +10,9 @@
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
#include <system_error>
|
||||
#include <stdfloat>
|
||||
#if __cplusplus >= 202300L || _MSVC_LANG >= 202300L
|
||||
#include <stdfloat>
|
||||
#endif
|
||||
namespace fast_float {
|
||||
|
||||
|
||||
@ -137,8 +139,9 @@ template<typename T, typename UC>
|
||||
FASTFLOAT_CONSTEXPR20
|
||||
from_chars_result_t<UC> 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<T, std::float32_t>::value){
|
||||
float value32;
|
||||
@ -146,9 +149,9 @@ from_chars_result_t<UC> 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<T, std::float64_t>::value){
|
||||
double value64;
|
||||
@ -156,6 +159,7 @@ from_chars_result_t<UC> from_chars(UC const * first, UC const * last,
|
||||
value = value64;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
return from_chars_advanced(first, last, value, parse_options_t<UC>{fmt});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user