C++ Logo

STD-DISCUSSION

Advanced search

Subject: Re: add version of std::stoi, std::stol etc that receive std::string_view
From: Thiago Macieira (thiago_at_[hidden])
Date: 2020-09-01 14:35:20


On Tuesday, 1 September 2020 08:16:56 PDT Jason McKesson via Std-Discussion
wrote:
> Also, we already have `to_chars` and `from_chars`, which are quite
> fast and do not allocate memory. We've had them since C++17 (though
> standard library implementations took a while).

But they are not the same. std::stoi for example handles base = 0 and
interpreting the prefixes, as it's defined to do the same as strtol does.
std::from_chars, however, does no prefix interpretation and therefore requires
a non-zero base.

This discrepancy is slightly annoying. It moves a set of functions that would
be really useful to the column of "cumbersome to use". Since stoi does the
same as strtol, what's the value?

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DPG Cloud Engineering

STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups