Not saying that you can’t do that. But the standard is big enough as it is, you don’t need to duplicate the same algorithms to the same thing in a different way.

You can use from_chars, but this is such a simple and common task there should be an easy way to do it without having to work around string_view ergonomics issues.

This is a simple one-liner in just about every other language, it would look silly if the idiomatic solution in C++ was dealing with from_chars.

Cheers,
Jeremy

On Mon, Jan 13, 2025 at 14:59 Tiago Freire via Std-Proposals <std-proposals@lists.isocpp.org> wrote:

> Why not change std::stoi to be that one-liner, which is almost what's being proposed?

 

Not saying that you can’t do that. But the standard is big enough as it is, you don’t need to duplicate the same algorithms to the same thing in a different way.

 

<charconv> already covers almost all cases, you can use it with a view, it covers more int types than stoi/stoull family does, it covers floats.

The only thing that it doesn’t cover as a use case is buffer size estimates (which nothing in the standard does).

--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals