summaryrefslogtreecommitdiff
path: root/asl/strings/parse_number_float.cpp
blob: 4568278c07739cfed4d20aad955d9b73801517e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright 2025 Steven Le Rouzic
//
// SPDX-License-Identifier: BSD-3-Clause

#include <fast_float.h>

// We need to isolate fast_float.h completely from asl
// because it conflicts with our redefinitions of things
// from the STL. In this case it's operator new, but there
// might be other conflicts.

namespace asl
{

extern bool parse_float_impl(const char** begin, const char* end, float* value)
{
    auto res = fast_float::from_chars(*begin, end, *value);
    *begin = res.ptr;
    return res.ec == std::errc{};
}

extern bool parse_double_impl(const char** begin, const char* end, double* value)
{
    auto res = fast_float::from_chars(*begin, end, *value);
    *begin = res.ptr;
    return res.ec == std::errc{};
}

} // namespace asl