C++ Logo

std-proposals

Advanced search

Re: [std-proposals] string_view support for std::stoi and friends

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Mon, 13 Jan 2025 21:05:55 +0000
On Mon, 13 Jan 2025 at 20:59, Tiago Freire <tmiguelf_at_[hidden]> 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,
>

How? It requires a pair of pointers.


> it covers more int types than stoi/stoull family does, it covers floats.
>

Like stof/stod/stold.

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

Received on 2025-01-13 21:07:22