C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Should std::to_string be deprecated?

From: Andrey Semashev <andrey.semashev_at_[hidden]>
Date: Wed, 4 Oct 2023 16:08:03 +0300
On 10/4/23 15:26, Jonathan Sweemer via Std-Proposals wrote:
> Hello,
>
> I recently came across P2587 "to_string or not to_string", which has
> been accepted for C++26, and I am wondering whether there has since been
> any attempt to deprecate std::to_string?
>
> The motivation would be to consolidate on std::format, which
> std::to_string is now (as of C++26) defined in terms of, thereby making
> the standard library marginally smaller and easier to teach (in my opinion).
>
> If this is a stupid idea, then can you kindly inform me of the role that
> std::to_string is intended to play in the language for C++26 and beyond?

Please don't deprecate std::to_string. I do not want to have to use
std::format whenever I need to stringify an int. Its interface is too
cumbersome for such a trivial task.

Also, even if std::to_string is defined in terms of std::format (I
haven't checked), I sure hope that it isn't implemented that way, as
that would be very inefficient. Specifically, std::to_string does not
need to parse any format string in order to produce its result.

Received on 2023-10-04 13:08:18