Date: Mon, 13 Jan 2025 20:56:10 +0000
On Mon, 13 Jan 2025 at 20:51, Jonathan Wakely <cxx_at_[hidden]> wrote:
>
>
> On Mon, 13 Jan 2025 at 20:30, Tiago Freire <tmiguelf_at_[hidden]> wrote:
>
>> > > Isn't <charconv> already locale independent?
>> > > In what way after C++17 would stoi not be obsolete?
>>
>> > Seriously?
>>
>>
>>
>> > Because std::stoi(function_returning_string()) is much simpler than:
>>
>>
>>
>> > auto str = function_returning_string();
>>
>> > int i;
>>
>> > if (auto [ptr, ec] = std::from_chars(str.data(), str.data()+str.size(),
>> i); ec)
>>
>>
>>
>>
>>
>> I’m going to double down on this.
>>
>> Looks simpler, takes longer.
>>
>> If you insist having it a one liner, just wrap it up in a function, you
>> would still be saving a lot of time.
>>
>
> Why not change std::stoi to be that one-liner, which is almost what's
> being proposed?
>
>
>
Or at least do something like P2007 and/or P2584 , so that std::from_chars
is simpler to use. Why should everybody reimplement the function to make it
less low-level?
>
>
> On Mon, 13 Jan 2025 at 20:30, Tiago Freire <tmiguelf_at_[hidden]> wrote:
>
>> > > Isn't <charconv> already locale independent?
>> > > In what way after C++17 would stoi not be obsolete?
>>
>> > Seriously?
>>
>>
>>
>> > Because std::stoi(function_returning_string()) is much simpler than:
>>
>>
>>
>> > auto str = function_returning_string();
>>
>> > int i;
>>
>> > if (auto [ptr, ec] = std::from_chars(str.data(), str.data()+str.size(),
>> i); ec)
>>
>>
>>
>>
>>
>> I’m going to double down on this.
>>
>> Looks simpler, takes longer.
>>
>> If you insist having it a one liner, just wrap it up in a function, you
>> would still be saving a lot of time.
>>
>
> Why not change std::stoi to be that one-liner, which is almost what's
> being proposed?
>
>
>
Or at least do something like P2007 and/or P2584 , so that std::from_chars
is simpler to use. Why should everybody reimplement the function to make it
less low-level?
Received on 2025-01-13 20:57:28