<div dir="ltr"><div>That would result in char being printed out as an int value, e.g. 65 instead of &#39;A&#39;, which is inconsistent with std::format(&quot;{}&quot;, &#39;A&#39;). If there is a generic version of std::to_string then it should produce the same result as std::format, no?</div><div><br></div><div>By the way, in your earlier email you mentioned the formatable&lt;char&gt; concept to constrain a hypothetical generic version of std::to_string. Does this concept exist already, and if so, why isn&#39;t it used on std::format itself, which as far as I can tell, is currently unconstrained?</div><div dir="ltr"><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Oct 5, 2023 at 9:52 PM Jonathan Wakely &lt;<a href="mailto:cxx@kayari.org" target="_blank">cxx@kayari.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"><div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 5 Oct 2023, 12:53 Jonathan Sweemer via Std-Proposals, &lt;<a href="mailto:std-proposals@lists.isocpp.org" target="_blank">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"><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></font></div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">requires(const T&amp; t) {</div><div dir="auto">  { std::to_string(t) } -&gt; std::same_as&lt;std::string&gt;;</div><div dir="auto">};</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><font face="monospace">  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" rel="noreferrer" target="_blank">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" rel="noreferrer" target="_blank">Std-Proposals@lists.isocpp.org</a><br>
<a href="https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals" rel="noreferrer noreferrer" target="_blank">https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals</a><br>
</blockquote></div></div>
-- <br>
Std-Proposals mailing list<br>
<a href="mailto:Std-Proposals@lists.isocpp.org" rel="noreferrer" target="_blank">Std-Proposals@lists.isocpp.org</a><br>
<a href="https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals" rel="noreferrer noreferrer" target="_blank">https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals</a><br>
</blockquote></div></div></div>
</blockquote></div></div>
</div>

