Boost logo

Boost :

From: Matt Borland (matt_at_[hidden])
Date: 2024-01-31 12:23:08


> I'm not a reviewer, but I'd like to add a note on the interface:
>

> I think boost::charconv should add one convenience function as follows:
>

> // Returns std::nullopt on error
> template <typename NumberType>
>

> std::optional<NumberType> boost::charconv::to_number(const
>

> std::string_view& sv) noexcept;
>

> Reason:
> Right now there is no simple, non-throwing way of converting a string to a
> number in C++ as std::stoi/std::stof throws exceptions on errors.
>

> Best/Viktor
>

Viktor,

Thanks for the suggestion. I can add some additional interfaces for to/from number to the library since they are pretty straightforward. Similar comments came up during the review such as supporting string_view instead of pointer pairs.

Matt





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