Opened 11 years ago

#6454 new Bugs

Problem when using phoenix::_if with boost::optional in Spirit

Reported by: Öyvind Strand <oyvind.strand@…> Owned by: Thomas Heller
Milestone: To Be Determined Component: phoenix
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:

Description

A rule that yields a boost::optional as attribute won't compile when using qi::_1 as condition for phoenix::_if. However, if you add a phoenix statement after the if_ statement the rule compiles.

Doesn't compile qi::rule<Iter, boost::optional<int>()> rule_a =

(-qi::int_)[

phx::if_(qi::_1)[

phx::nothing

] Uncomment next line and it compiles , phx::nothing

]

;

It doesn't help if you use another operator than -

Doesn't compile qi::rule<Iter, boost::optional< boost::variant<int, double> >() > rule_b =

(qi::int_ | qi::double_ | qi::eps)[

phx::if_(qi::_1)[

phx::nothing

] Uncomment next line and it compiles , phx::nothing

]

;

The error doesn't manifest if you don't refer to qi::_1

Compiles qi::rule<Iter, boost::optional< boost::variant<int, double> >() > rule_c =

(qi::int_ | qi::double_ | qi::eps)[

phx::if_(phx::val(true))[

phx::nothing

]

]

;

It also works if you refer to qi::_1 but don't use phoenix::if_

Compiles qi::rule<Iter, boost::optional<int>()> rule_d =

(-qi::int_)[

std::cout << qi::_1

]

;

Doing the same thing as in rule_a and rule_b outside of Spirit semantic actions also works

Compiles phx::if_(arg1)[

phx::nothing

] (boost::optional<int>(5));

The problem doesn't seem to occur when using Phoenix v2 only v3

Attachments (1)

test_phoenix_if.cpp (1.2 KB ) - added by Öyvind Strand <oyvind.strand@…> 11 years ago.
Self-contained test case

Download all attachments as: .zip

Change History (1)

by Öyvind Strand <oyvind.strand@…>, 11 years ago

Attachment: test_phoenix_if.cpp added

Self-contained test case

Note: See TracTickets for help on using tickets.