<div dir="auto">Where do I forward to ostream?<div dir="auto"><br></div><div dir="auto">lazy_string:s main purpose was not originally to just provide a means to do format for streams, but rather make this:</div><div dir="auto">```cpp</div><div dir="auto">std::string str = ...; // initialised by something </div><div dir="auto">...</div><div dir="auto">str = lazy_format(&quot;...&quot;...);</div><div dir="auto">```</div><div dir="auto">as efficient as:</div><div dir="auto">```cpp</div><div dir="auto">str.clear();</div><div dir="auto">format_to(std::back_inserter(str), &quot;...&quot;...);</div><div dir="auto">```</div><div dir="auto">.</div><div dir="auto">When the question for interoperability between new formattable types and old ostreams arrised, I added a second use-case for it. But if that is not desirable, then I can omit it.</div><div dir="auto"><br></div><div dir="auto">// Robin</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Dec 14, 2024, 17:48 Victor Zverovich 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">&gt; The std::chrono formatters do for empty chrono specs.<br><br>The whole formatter specialization is not defined by forwarding to ostream though. Describing a subset of outputs in terms of other APIs is a bit different and just a matter of avoiding duplication in the spec.<div><br></div><div>- Victor</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Dec 14, 2024 at 8:01 AM Jonathan Wakely &lt;<a href="mailto:cxx@kayari.org" target="_blank" rel="noreferrer">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 Sat, 14 Dec 2024, 15:28 Victor Zverovich via Std-Proposals, &lt;<a href="mailto:std-proposals@lists.isocpp.org" target="_blank" rel="noreferrer">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">I would also add that forwarding to ostream is almost always a bad idea and none of the standard formatters do that for very good reasons</div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">The std::chrono formatters do for empty chrono specs.</div><div dir="auto"><br></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"> (even basic things like padding are incompatible because ostreams don&#39;t work with Unicode). It is probably OK as an opt in for quick and dirty debugging code but nothing more than that.<div><br></div><div>Cheers,</div><div>Victor</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Dec 12, 2024 at 11:49 AM Tiago Freire via Std-Proposals &lt;<a href="mailto:std-proposals@lists.isocpp.org" rel="noreferrer 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"><div>





<div lang="EN-US">
<div>
<p class="MsoNormal">I would be against an automatic adaptors of this nature.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Facilities such as std::format and std::basic_ostream are 2 different families of API’s, although their purpose overlap they are fundamentally different things and work under two different philosophies. And I would hope the “std::basic_ostream”
 family to be completely removed in the future.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0cm 0cm">
<p class="MsoNormal"><b><span style="font-size:11pt;font-family:Calibri,sans-serif">From:</span></b><span style="font-size:11pt;font-family:Calibri,sans-serif"> Std-Proposals &lt;<a href="mailto:std-proposals-bounces@lists.isocpp.org" rel="noreferrer noreferrer" target="_blank">std-proposals-bounces@lists.isocpp.org</a>&gt;
<b>On Behalf Of </b>Robin Savonen Söderholm via Std-Proposals<br>
<b>Sent:</b> Thursday, December 12, 2024 2:23 PM<br>
<b>To:</b> <a href="mailto:std-proposals@lists.isocpp.org" rel="noreferrer noreferrer" target="_blank">std-proposals@lists.isocpp.org</a><br>
<b>Cc:</b> Robin Savonen Söderholm &lt;<a href="mailto:robinsavonensoderholm@gmail.com" rel="noreferrer noreferrer" target="_blank">robinsavonensoderholm@gmail.com</a>&gt;<br>
<b>Subject:</b> [std-proposals] Format output-streamable types?<u></u><u></u></span></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">Hi!<br>
<br>
I enjoy the `format`, `format_to` and `print`-facilities that came with C++20 and 23 (coming from the fmt-library) but I just noticed that I can&#39;t format e.g. std::bitset. Bitset, however, do have an operator&lt;&lt;() defined which should be usable in the format
 context. So I made a very basic, proof-of-concept streambuf-derived type that could take an output iterator and wrap it inside streambuf:s API so that it was possible to call the operator&lt;&lt;() with an arbitrary output (char) iterator. I.e. I could do a formatter::format-function
 that just delegated the work to the operator&lt;&lt;().<br>
<br>
I do however, wonder if it is best to just ask for the formatter to be specialised for all types that already have an operator&lt;&lt; (as it may arguably be slightly faster and removes the need of vtable calls inside the format function) or if it actually is desirable
 to have a default specialisation that says &quot;incase of an operator&lt;&lt;(basic_ostreambuf&lt;Char...&gt;&amp;, T const&amp;) exist, use it for formatting&quot;. I could also think of a hybrid version where manual specialisation of std-types are made as well as the iterator-to-stream_buf
 type that can be used by users that do not want to re-implement their type-to-string logic.<br>
<br>
Thoughts?<br>
<br>
// Robin<u></u><u></u></p>
</div>
</div>
</div>

-- <br>
Std-Proposals mailing list<br>
<a href="mailto:Std-Proposals@lists.isocpp.org" rel="noreferrer noreferrer" target="_blank">Std-Proposals@lists.isocpp.org</a><br>
<a href="https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals" rel="noreferrer noreferrer noreferrer" target="_blank">https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals</a><br>
</div></blockquote></div>
-- <br>
Std-Proposals mailing list<br>
<a href="mailto:Std-Proposals@lists.isocpp.org" rel="noreferrer noreferrer" target="_blank">Std-Proposals@lists.isocpp.org</a><br>
<a href="https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals" rel="noreferrer noreferrer noreferrer" target="_blank">https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals</a><br>
</blockquote></div></div></div>
</blockquote></div>
-- <br>
Std-Proposals mailing list<br>
<a href="mailto:Std-Proposals@lists.isocpp.org" target="_blank" rel="noreferrer">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>

