Date: Mon, 13 Jan 2025 22:52:16 +0000
On Mon, 13 Jan 2025, 21:42 Thiago Macieira via Std-Proposals, <
std-proposals_at_[hidden]> wrote:
> On Monday 13 January 2025 12:51:51 Pacific Standard Time Jonathan Wakely
> via
> Std-Proposals wrote:
> > Why not change std::stoi to be that one-liner, which is almost what's
> being
> > proposed?
>
> Because it isn't. And that's the issue: stoi does more than just parse the
> numbers. It also handles whitespace before the number, the plus sign, and
> 0,
> 0b and 0x prefix for when applicable for the base in question.
>
But that's another reason why "just use from_chars, it's faster anyway"
isn't a good answer, and saying that std::stoi serves no purpose is wrong.
If you actually want the strtoll-like behaviour then using from_chars takes
even more effort.
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.
std-proposals_at_[hidden]> wrote:
> On Monday 13 January 2025 12:51:51 Pacific Standard Time Jonathan Wakely
> via
> Std-Proposals wrote:
> > Why not change std::stoi to be that one-liner, which is almost what's
> being
> > proposed?
>
> Because it isn't. And that's the issue: stoi does more than just parse the
> numbers. It also handles whitespace before the number, the plus sign, and
> 0,
> 0b and 0x prefix for when applicable for the base in question.
>
But that's another reason why "just use from_chars, it's faster anyway"
isn't a good answer, and saying that std::stoi serves no purpose is wrong.
If you actually want the strtoll-like behaviour then using from_chars takes
even more effort.
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.
Received on 2025-01-13 22:53:36