Boost C++ Libraries: Ticket #4910: ambiguity of operator<< in display_expr https://svn.boost.org/trac10/ticket/4910 <p> from here: <a class="ext-link" href="http://cpp-next.com/archive/2010/09/expressive-c-playing-with-syntax/comment-page-1/#comment-1134"><span class="icon">​</span>http://cpp-next.com/archive/2010/09/expressive-c-playing-with-syntax/comment-page-1/#comment-1134</a> </p> <div class="wiki-code"><div class="code"><pre><span class="k">struct</span> <span class="n">A</span> <span class="p">{};</span> <span class="k">struct</span> <span class="nl">B</span><span class="p">:</span><span class="n">A</span> <span class="p">{};</span> <span class="n">std</span><span class="o">::</span><span class="n">ostream</span><span class="o">&amp;</span> <span class="k">operator</span><span class="o">&lt;&lt;</span><span class="p">(</span> <span class="n">std</span><span class="o">::</span><span class="n">ostream</span><span class="o">&amp;</span> <span class="n">out</span><span class="p">,</span> <span class="k">const</span> <span class="n">A</span><span class="o">&amp;</span> <span class="p">)</span> <span class="p">{</span> <span class="k">return</span> <span class="n">out</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;this is A!&quot;</span><span class="p">;</span> <span class="p">}</span> </pre></div></div><p> If you do </p> <div class="wiki-code"><div class="code"><pre><span class="n">proto</span><span class="o">::</span><span class="n">display_expr</span><span class="p">(</span> <span class="n">map</span><span class="p">(</span> <span class="n">A</span><span class="p">(),</span> <span class="mi">1</span> <span class="p">)</span> <span class="p">);</span> </pre></div></div><p> it works, but if you do </p> <div class="wiki-code"><div class="code"><pre><span class="n">proto</span><span class="o">::</span><span class="n">display_expr</span><span class="p">(</span> <span class="n">map</span><span class="p">(</span> <span class="n">B</span><span class="p">(),</span> <span class="mi">1</span> <span class="p">)</span> <span class="p">);</span> </pre></div></div><p> it doesn't compile due to ambiguity introduced by <code>hidden_detail_::operator&lt;&lt;</code> that does this nice typeid output. </p> <p> The patch for <code>boost/proto/debug.hpp</code> against 1.44.0 (works for me) and last revision 66440 (not tried to compile, just by analogy) is attached. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4910 Trac 1.4.3 Maxim Yanchenko <Maxim.Yanchenko@…> Tue, 30 Nov 2010 02:57:20 GMT attachment set https://svn.boost.org/trac10/ticket/4910 https://svn.boost.org/trac10/ticket/4910 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">display_expr-1.44.0.patch</span> </li> </ul> <p> patch against 1.44.0 </p> Ticket Maxim Yanchenko <Maxim.Yanchenko@…> Tue, 30 Nov 2010 02:57:44 GMT attachment set https://svn.boost.org/trac10/ticket/4910 https://svn.boost.org/trac10/ticket/4910 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">display_expr-66440.patch</span> </li> </ul> <p> patch against rev. 66440 </p> Ticket Maxim Yanchenko <Maxim.Yanchenko@…> Tue, 30 Nov 2010 07:16:08 GMT attachment set https://svn.boost.org/trac10/ticket/4910 https://svn.boost.org/trac10/ticket/4910 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">display_expr-1.44.0.2.patch</span> </li> </ul> <p> patch against 1.44.0 </p> Ticket Maxim Yanchenko <Maxim.Yanchenko@…> Tue, 30 Nov 2010 07:16:54 GMT attachment set https://svn.boost.org/trac10/ticket/4910 https://svn.boost.org/trac10/ticket/4910 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">display_expr-66440.2.patch</span> </li> </ul> <p> patch against rev. 66440 </p> Ticket Maxim Yanchenko <Maxim.Yanchenko@…> Tue, 30 Nov 2010 07:33:52 GMT <link>https://svn.boost.org/trac10/ticket/4910#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4910#comment:1</guid> <description> <p> The patches <code>&lt;xxx&gt;.2.patch</code> are slightly simpler and cleaner than the first submitted (can't delete them myself, so please feel free to delete). There is a self-written <code>has_ostream_shift&lt;T&gt;</code> trait, not sure if we already have one in Boost. If so, please feel free to replace with the blessed one. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Eric Niebler</dc:creator> <pubDate>Mon, 20 Dec 2010 15:57:47 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4910#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4910#comment:2</guid> <description> <p> Attempted fix in <a class="changeset" href="https://svn.boost.org/trac10/changeset/67366" title="attempted fix for 4910">[67366]</a>. Let's see how the new display_expr tests fare on trunk. </p> </description> <category>Ticket</category> </item> <item> <author>Peter Schüller <schueller.p@…></author> <pubDate>Tue, 21 Dec 2010 09:22:26 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4910#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4910#comment:3</guid> <description> <p> sorry to say that, but <a class="changeset" href="https://svn.boost.org/trac10/changeset/67366" title="attempted fix for 4910">[67366]</a> broke something: </p> <p> define the following function inline solves the problem (line 105 in debug.hpp): </p> <pre class="wiki"> inline std::ostream &amp;operator &lt;&lt;(ostream_wrapper sout_wrap, named_any t) </pre><p> otherwise I get duplicate symbol definitions if I use spirit in two compilation units: </p> <pre class="wiki">/...path.../proto/debug.hpp:105: multiple definition of `boost::proto::hidden_detail_::operator&lt;&lt;(boost::proto::hidden_detail_::ostream_wrapper, boost::proto::hidden_detail_::named_any)' </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Eric Niebler</dc:creator> <pubDate>Tue, 21 Dec 2010 14:39:11 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4910#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4910#comment:4</guid> <description> <p> oops. should be fixed in <a class="changeset" href="https://svn.boost.org/trac10/changeset/67386" title="add missing inline">[67386]</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Eric Niebler</dc:creator> <pubDate>Tue, 21 Dec 2010 15:07:41 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4910#comment:5 https://svn.boost.org/trac10/ticket/4910#comment:5 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/67387" title="fix ambiguity in display_expr, fixes #4910">[67387]</a>) fix ambiguity in display_expr, fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4910" title="#4910: Patches: ambiguity of operator&lt;&lt; in display_expr (closed: fixed)">#4910</a> </p> Ticket