C++ Logo

std-proposals

Advanced search

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

From: tzsz <writing.segfaults_at_[hidden]>
Date: Tue, 14 Jan 2025 12:11:12 +0100
This isn't a real killer features. It is one of those convenience
features like min, max, clamp, ceil that are easily implemented in a
project but are still provided so developers don't have to do this over
and over again.

Furthermore, developers coming to C++ are probably going to stumble
across stoi first and try to use that. Having from_chars as an
exception-less alternative is good but not all code is written like that
and stoi should then give the best possible performance and usability.

Am 14.01.25 um 07:34 schrieb Tiago Freire via Std-Proposals:
>
> > If we make stoi work with string_view then it has advantages over
> strtoll and the existing stoi(const string&), and can still be faster
> than strtoll. There's room for something between the lower level, less
> flexible from_chars behaviour and the current stoi family.
>
> Ok. Then what exactly is it that std::stoi does differently in terms
> of behavior that in your view justifies “hey you know what, we need
> this for this killer feature, and that is worth all the trouble to
> make it standard and maintaining it in all major libraries”?
>
>

Received on 2025-01-14 11:11:15