diff --git a/include/fast_float/float_common.h b/include/fast_float/float_common.h index a7dfac0..a093c92 100644 --- a/include/fast_float/float_common.h +++ b/include/fast_float/float_common.h @@ -7,7 +7,11 @@ #include #include #include - +#ifdef __has_include + #if __has_include() + #include + #endif +#endif #include "constexpr_feature_detect.h" namespace fast_float { @@ -188,7 +192,14 @@ fastfloat_really_inline constexpr bool cpp20_and_in_constexpr() { template fastfloat_really_inline constexpr bool is_supported_float_type() { - return std::is_same::value || std::is_same::value; + return std::is_same::value || std::is_same::value +#if __STDCPP_FLOAT32_T__ + || std::is_same::value +#endif +#if __STDCPP_FLOAT64_T__ + || std::is_same::value +#endif + ; } template diff --git a/include/fast_float/parse_number.h b/include/fast_float/parse_number.h index 2cac4a8..0c02a42 100644 --- a/include/fast_float/parse_number.h +++ b/include/fast_float/parse_number.h @@ -10,11 +10,6 @@ #include #include #include -#ifdef __has_include - #if __has_include() - #include - #endif -#endif namespace fast_float { @@ -189,6 +184,7 @@ template FASTFLOAT_CONSTEXPR20 from_chars_result_t from_chars(UC const * first, UC const * last, T &value, chars_format fmt /*= chars_format::general*/) noexcept { +printf("from_chars to call\n"); return from_chars_caller::call(first, last, value, parse_options_t(fmt)); } @@ -197,7 +193,7 @@ FASTFLOAT_CONSTEXPR20 from_chars_result_t from_chars_advanced(UC const * first, UC const * last, T &value, parse_options_t options) noexcept { - static_assert (is_supported_float_type(), "only float and double are supported"); + static_assert (is_supported_float_type(), "only some floating-point types are supported"); static_assert (is_supported_char_type(), "only char, wchar_t, char16_t and char32_t are supported"); from_chars_result_t answer; diff --git a/tests/fixedwidthtest.cpp b/tests/fixedwidthtest.cpp index 6fc35e9..6f32395 100644 --- a/tests/fixedwidthtest.cpp +++ b/tests/fixedwidthtest.cpp @@ -12,7 +12,7 @@ int main() { #if __STDCPP_FLOAT32_T__ const std::vector float32_test_expected{123.456f, -78.9f, 0.0001f, 3.40282e+038f}; const std::vector float32_test{"123.456", "-78.9", "0.0001", "3.40282e+038"}; - + std::cout << "runing float32 test" << std::endl; for (std::size_t i = 0; i < float32_test.size(); ++i) { const auto& f = float32_test[i]; std::float32_t result; @@ -35,7 +35,7 @@ int main() { // Test cases for std::float64_t const std::vector float64_test_expected{1.23e4, -5.67e-8, 1.7976931348623157e+308, -1.7976931348623157e+308}; const std::vector float64_test{"1.23e4", "-5.67e-8", "1.7976931348623157e+308", "-1.7976931348623157e+308"}; - + std::cout << "runing float64 test" << std::endl; for (std::size_t i = 0; i < float64_test.size(); ++i) { const auto& f = float64_test[i]; std::float64_t result; @@ -45,8 +45,8 @@ int main() { std::cerr << "Failed to parse: \"" << f << "\"" << std::endl; return EXIT_FAILURE; } - if(result != float32_test_expected[i]) { - std::cerr << "Test failed for input: \"" << f << "\" expected " << float32_test_expected[i] << " got " << result << std::endl; + if(result != float64_test_expected[i]) { + std::cerr << "Test failed for input: \"" << f << "\" expected " << float64_test_expected[i] << " got " << result << std::endl; return EXIT_FAILURE; } }