Opened 7 years ago
Closed 3 years ago
#12082 closed Bugs (wontfix)
x3::forward_ast ambiguous call
Reported by: | Owned by: | Joel de Guzman | |
---|---|---|---|
Milestone: | To Be Determined | Component: | spirit |
Version: | Boost 1.60.0 | Severity: | Problem |
Keywords: | Cc: |
Description
Following code works for boost::variant but fails for boost::spirit::x3::variant with error: call of '(const c) (boost::spirit::x3::forward_ast<s1>&)' is ambiguous
#define USE_SPIRIT_X3_VARIANT 1 #include <boost/fusion/include/define_struct_inline.hpp> #include <boost/spirit/home/x3/support/ast/variant.hpp> #include <boost/variant.hpp> struct s1; #if USE_SPIRIT_X3_VARIANT == 1 using s2 = boost::spirit::x3::variant<long, boost::spirit::x3::forward_ast<s1> >; #else using s2 = boost::variant<long, boost::recursive_wrapper<s1> >; #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); }
http://melpon.org/wandbox/permlink/BPdeuyNPLINriCr3
As you can see, magic
class does not belong to the variant, but still causes compilation error.
Change History (7)
comment:1 by , 7 years ago
comment:2 by , 7 years ago
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.
comment:3 by , 7 years ago
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.
comment:4 by , 7 years ago
Both of ADAPT_STRUCT and _INLINE have sequence conversion ctor, thus ADAPT_STRUCT doesn't help in this case as same error http://melpon.org/wandbox/permlink/zVVrJ2TWHhRy76re .
comment:5 by , 7 years ago
I'm confused. That one uses BOOST_FUSION_DEFINE_STRUCT. This one compiles: http://melpon.org/wandbox/permlink/DSACLZOSLtg27kis
comment:7 by , 3 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
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.