SpaceIm 2021-04-07 16:05:17 +02:00 committed by GitHub
parent 73242b26c4
commit 780bbe5d6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,9 +13,6 @@
#include <cctype> #include <cctype>
#if __has_include(<charconv>) #if __has_include(<charconv>)
#include <charconv> #include <charconv>
#define CPPPEGLIB_HAS_CHARCONV true
#else
#define CPPPEGLIB_HAS_CHARCONV false
#endif #endif
#include <cstring> #include <cstring>
#include <functional> #include <functional>
@ -343,8 +340,12 @@ inline std::string resolve_escape_sequence(const char *s, size_t n) {
template <typename T> T token_to_number_(std::string_view sv) { template <typename T> T token_to_number_(std::string_view sv) {
T n = 0; T n = 0;
if constexpr (CPPPEGLIB_HAS_CHARCONV && !std::is_floating_point<T>::value) { #if __has_include(<charconv>)
if constexpr (!std::is_floating_point<T>::value) {
std::from_chars(sv.data(), sv.data() + sv.size(), n); std::from_chars(sv.data(), sv.data() + sv.size(), n);
#else
if constexpr (false) {
#endif
} else { } else {
auto s = std::string(sv); auto s = std::string(sv);
std::istringstream ss(s); std::istringstream ss(s);