Boost logo

Boost :

From: Ruben Perez (rubenperez038_at_[hidden])
Date: 2024-01-17 10:17:15


> > There is an open issue with LWG here:https://cplusplus.github.io/LWG/lwg-active.html#3081. The standard for <charconv> does not distinguish between underflow and overflow like strtod does. Let's say you are writing a JSON library and you replace strtod with charconv for performance reasons. Charconv returns std::errc::result_out_of_range on some conversion. Now what? You would have to parse the string again yourself to figure out which of the four possible reasons you got std::errc::result_out_of_range. Charconv already had this information but could not give it to you. By implementing the resolution to the LWG issue that matches the established strtod behavior I think we are providing the correct behavior without waiting on the committee. Andrzej did bring this up as well, and a macro BOOST_CHARCONV_STD_ERANGE was added to match what the standard says today.
>
> After reading this and the related issue
> (https://github.com/cppalliance/charconv/issues/110) I actually strongly
> oppose the existing macro BOOST_CHARCONV_STD_ERANGE.
>
> It doesn't change the behavior of the users application but that of the
> compiled (Boost) library. And if given a compiled library there is a) no
> way to know the actual behavior of `from_chars` and b) there could be(?)
> ODR violations when using the library statically.
>

Now that I understand the rationale, I also advocate for keeping the
current behavior and removing BOOST_CHARCONV_STD_ERANGE.

Matt, I'd also ask to include the rationale that you provided in the docs.

Thanks,
Ruben.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk