<div dir="ltr"><div>I would say yes, if the general consensus is that std::to_string is useful and should not be deprecated, then at least it should be made more generic.</div><div><br></div><div>The current list of overloads for std::to_string seems a bit arbitrary and incomplete to me, with char being the most error-prone example, as it happily binds to the overload taking int.</div><div><br></div><div>If you know you&#39;re dealing with ints, then I agree that std::to_string provides a more simple syntax for converting to a string, but in any generic code you either have to use std::format (i.e. forget about std::to_string), or do something like the following to delegate between the two:</div><div><br></div><div><font face="monospace">template&lt;typename T&gt;<br>concept to_stringable =<br>  std::is_same_v&lt;T, int&gt; ||<br>  std::is_same_v&lt;T, long&gt; ||<br>  std::is_same_v&lt;T, long long&gt; ||<br>  std::is_same_v&lt;T, unsigned&gt; ||<br>  std::is_same_v&lt;T, unsigned long&gt; ||<br>  std::is_same_v&lt;T, unsigned long long&gt; ||<br>  std::is_same_v&lt;T, float&gt; ||<br>  std::is_same_v&lt;T, double&gt; ||<br>  std::is_same_v&lt;T, long double&gt;;<br><br>template&lt;typename T&gt;<br>auto generic_to_string(const T&amp; t) {<br>  if constexpr (to_stringable&lt;T&gt;) {<br>    return std::to_string(t);<br>  } else {<br>    return std::format(&quot;{}&quot;, t);<br>  }<br>}<br></font><br></div><div>But the to_stringable concept is very brittle to maintain, because new overloads might be added in future versions of the standard, so a truly generic version of std::to_string would be more desirable in my view.</div><div><br></div><div><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Oct 5, 2023 at 4:56 PM Giuseppe D&#39;Angelo via Std-Proposals &lt;<a href="mailto:std-proposals@lists.isocpp.org">std-proposals@lists.isocpp.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Il 04/10/23 22:38, Victor Zverovich via Std-Proposals ha scritto:<br>
&gt; At the very least std::to_string is a useful shorthand notation for <br>
&gt; std::format for numeric types.<br>
&gt; <br>
<br>
But this prompts the question: would it would make sense to have a <br>
overload `to_string` taking just any formattable type?<br>
<br>
Thanks,<br>
-- <br>
Giuseppe D&#39;Angelo<br>
-- <br>
Std-Proposals mailing list<br>
<a href="mailto:Std-Proposals@lists.isocpp.org" target="_blank">Std-Proposals@lists.isocpp.org</a><br>
<a href="https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals" rel="noreferrer" target="_blank">https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals</a><br>
</blockquote></div></div>

