mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-12-22 11:55:30 +00:00
parent
ef10e7c5dd
commit
73242b26c4
10
peglib.h
10
peglib.h
@ -13,6 +13,9 @@
|
||||
#include <cctype>
|
||||
#if __has_include(<charconv>)
|
||||
#include <charconv>
|
||||
#define CPPPEGLIB_HAS_CHARCONV true
|
||||
#else
|
||||
#define CPPPEGLIB_HAS_CHARCONV false
|
||||
#endif
|
||||
#include <cstring>
|
||||
#include <functional>
|
||||
@ -340,12 +343,7 @@ inline std::string resolve_escape_sequence(const char *s, size_t n) {
|
||||
|
||||
template <typename T> T token_to_number_(std::string_view sv) {
|
||||
T n = 0;
|
||||
#if __has_include(<charconv>)
|
||||
if constexpr (!std::is_floating_point<T>::value) {
|
||||
std::from_chars(sv.data(), sv.data() + sv.size(), n);
|
||||
#else
|
||||
if constexpr (false) {
|
||||
#endif
|
||||
if constexpr (CPPPEGLIB_HAS_CHARCONV && !std::is_floating_point<T>::value) {
|
||||
std::from_chars(sv.data(), sv.data() + sv.size(), n);
|
||||
} else {
|
||||
auto s = std::string(sv);
|
||||
|
Loading…
Reference in New Issue
Block a user