<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 4 Jan 2023 at 22:37, Frederick Virchanza Gotham 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">On Wed, Jan 4, 2023 at 10:04 PM Andrey Semashev via Std-Proposals<br>
&lt;<a href="mailto:std-proposals@lists.isocpp.org" target="_blank">std-proposals@lists.isocpp.org</a>&gt; wrote:<br>
&gt; Even if you never call the<br>
&gt; operator&lt;&lt; in your program that uses std::any, the compiler still has to<br>
&gt; generate the implementation for it - for every type that you ever store<br>
&gt; in std::any. Eventually this makes std::any too expensive to use for<br>
&gt; more and more people.<br>
<br>
<br>
If none of the source files in your project have:<br>
<br>
    #include &lt;any_ostream&gt;<br>
<br>
then your program will never have the extra classes and functions I wrote.<br>
<br>
And even if you _do_ include my header file and never use anything in<br>
it, your compiler will eradicate unreachable code.<br>
<br>
I don&#39;t know why you think std::any has to become any more complicated<br>
or less efficient.<br></blockquote><div><br></div><div>I believe this was in reference to Giuseppe D&#39;Angelo&#39;s suggestion that std::any type-erase the `std::ostream&amp; &lt;&lt;` operation.</div><div><br></div><div>Note that `&lt;iostream&gt;` for formatting is on the path to deprecation; any new proposal should target `&lt;format&gt;`.</div><div><br></div><div>You also might want to take a look at the implementation in <a href="https://en.cppreference.com/w/cpp/utility/any/type">https://en.cppreference.com/w/cpp/utility/any/type</a> since that looks to be significantly more efficient than yours.</div></div></div>

