Subject: [Boost-bugs] [Boost C++ Libraries] #6454: Problem when using phoenix::_if with boost::optional in Spirit
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-01-26 18:05:09
#6454: Problem when using phoenix::_if with boost::optional in Spirit
---------------------------------------------------+------------------------
Reporter: Ãyvind Strand <oyvind.strand@â¦> | Owner: theller
Type: Bugs | Status: new
Milestone: To Be Determined | Component: phoenix
Version: Boost Development Trunk | Severity: Problem
Keywords: |
---------------------------------------------------+------------------------
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
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/6454> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:08 UTC