Boost C++ Libraries: Ticket #12082: x3::forward_ast ambiguous call https://svn.boost.org/trac10/ticket/12082 <p> Following code works for boost::variant but fails for boost::spirit::x3::variant with <strong>error: call of '(const c) (boost::spirit::x3::forward_ast&lt;s1&gt;&amp;)' is ambiguous</strong> </p> <pre class="wiki">#define USE_SPIRIT_X3_VARIANT 1 #include &lt;boost/fusion/include/define_struct_inline.hpp&gt; #include &lt;boost/spirit/home/x3/support/ast/variant.hpp&gt; #include &lt;boost/variant.hpp&gt; struct s1; #if USE_SPIRIT_X3_VARIANT == 1 using s2 = boost::spirit::x3::variant&lt;long, boost::spirit::x3::forward_ast&lt;s1&gt; &gt;; #else using s2 = boost::variant&lt;long, boost::recursive_wrapper&lt;s1&gt; &gt;; #endif BOOST_FUSION_DEFINE_STRUCT_INLINE ( s1, (s2, v1) ) BOOST_FUSION_DEFINE_STRUCT_INLINE ( magic, (int*, v1) ) struct c { int operator()(long) const { return 0; } int operator()(s1) const { return 1; } int operator()(magic) const { return 3; } }; int main() { s2 s; s = s1{}; return boost::apply_visitor(c(), s); } </pre><p> <a class="ext-link" href="http://melpon.org/wandbox/permlink/BPdeuyNPLINriCr3"><span class="icon">​</span>http://melpon.org/wandbox/permlink/BPdeuyNPLINriCr3</a> </p> <p> As you can see, <code>magic</code> class does not belong to the variant, but still causes compilation error. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12082 Trac 1.4.3 Joel de Guzman Mon, 21 Mar 2016 03:09:44 GMT <link>https://svn.boost.org/trac10/ticket/12082#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12082#comment:1</guid> <description> <p> Confirmed. I think it is a bug with BOOST_FUSION_DEFINE_STRUCT_INLINE. Use BOOST_FUSION_ADAPT_STRUCT as a workaround. I suggest filing a bug against fusion. Damien Buhl is maintaining the adapt/define macros. I also suggest making a minimal test case with no Spirit X3 dependencies. The main issue is about calling a function object with two (or more?) operator() which are both fusion defined structs. Please close this ticket after filing the new ticket. </p> </description> <category>Ticket</category> </item> <item> <author>mikhail.strelnikov@…</author> <pubDate>Mon, 21 Mar 2016 11:36:23 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12082#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12082#comment:2</guid> <description> <p> But this example does not use Spirit X3 when USE_SPIRIT_X3_VARIANT macro is set to 0. If x3::variant is not used, this compiles and works as expected. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joel de Guzman</dc:creator> <pubDate>Mon, 21 Mar 2016 21:10:23 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12082#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12082#comment:3</guid> <description> <p> And it also compiles if you use BOOST_FUSION_ADAPT_STRUCT which leads me to think that USE_SPIRIT_X3_VARIANT is a red herring. I'll see if I can make a minimal test. </p> </description> <category>Ticket</category> </item> <item> <author>Kohei Takahashi <flast@…></author> <pubDate>Tue, 22 Mar 2016 07:25:10 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12082#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12082#comment:4</guid> <description> <p> Both of ADAPT_STRUCT and _INLINE have sequence conversion ctor, thus ADAPT_STRUCT doesn't help in this case as same error <a class="ext-link" href="http://melpon.org/wandbox/permlink/zVVrJ2TWHhRy76re"><span class="icon">​</span>http://melpon.org/wandbox/permlink/zVVrJ2TWHhRy76re</a> . </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joel de Guzman</dc:creator> <pubDate>Tue, 22 Mar 2016 09:03:46 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12082#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12082#comment:5</guid> <description> <p> I'm confused. That one uses BOOST_FUSION_DEFINE_STRUCT. This one compiles: <a class="ext-link" href="http://melpon.org/wandbox/permlink/DSACLZOSLtg27kis"><span class="icon">​</span>http://melpon.org/wandbox/permlink/DSACLZOSLtg27kis</a> </p> </description> <category>Ticket</category> </item> <item> <author>Kohei Takahashi <flast@…></author> <pubDate>Tue, 22 Mar 2016 09:13:59 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12082#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12082#comment:6</guid> <description> <p> Oops, it's my bad, sorry. You are right. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joel de Guzman</dc:creator> <pubDate>Thu, 25 Apr 2019 11:53:53 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/12082#comment:7 https://svn.boost.org/trac10/ticket/12082#comment:7 <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">wontfix</span> </li> </ul> Ticket