fast_float icon indicating copy to clipboard operation
fast_float copied to clipboard

Suggestion: provide from_chars_advanced overload or other function name that takes parsed_number_string_t<UC> argument

Open zejal opened this issue 1 year ago • 4 comments

Idea would be to allow for existing parsing code and avoid copy pasting remainder of from_chars_advanced function. Existing parser code would fill the parsed_number_string structure as appropriate.

zejal avatar May 11 '24 12:05 zejal

It is difficult to discuss these things in the abstract. My recommendation is that you make a pull request and we can look at the code.

lemire avatar May 11 '24 14:05 lemire

Not hugely familiar with github at this stage, unfortunately. Based on last released fast_float.hpp you'd have:

template<typename T, typename UC> FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC> from_chars_advanced(const parsed_number_string_t<UC>& pns, T &value) noexcept { // assert pns.valid ? or explicit check as in current function ? probably leave the check responsibility to caller ? answer.ec = std::errc(); // be optimistic // same lines as in existing from_chars_advanced. // ... }

zejal avatar May 11 '24 14:05 zejal

@zejal Can you propose a patch?

lemire avatar May 11 '24 17:05 lemire

Sure, I'll do my best to get familiar with how github works to work on changes.

zejal avatar May 11 '24 17:05 zejal