[Spirit Development][Phoenix]Assignment of fusion tuples fails in semantic actions.
Robert Nelson <[email protected]> Wed, 29 Dec 2010 21:22:07 -0700
| Newsgroups | gmane.comp.parsers.spirit.devel |
|---|---|
| Message-ID | <[email protected]> |
I am trying to assign a fusion tuple to a fusion adapted struct in a
semantic action, but it fails to compile. It says that there is no
equals operator defined. I did include the phoenix_operator header
this time ;)
I could of course write the = operator in the struct, but wouldn't
that kind of defeat the purpose of adapting it as a fusion sequence in
the first place? They are both proper fusion sequences; I really
think that assignment should be taken care of automatically.
This rule looks like it should work out of the box, but it doesn't.
rule<std::string::iterator,point()> value_rule = (int_ >> int_)[_val = _0];
Is this a bug, or do I need to write a custom = operator that takes a
fusion struct as a parameter?
Here is the full program.
#include <boost/spirit/include/qi.hpp>
#include <boost/fusion/adapted/struct/adapt_struct.hpp>
#include <boost/spirit/include/phoenix_fusion.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <string>
struct point
{
int x;
int y;
//point(const boost::fusion::vector2<int, int>& right); //why would I
need to manually write this?
};
BOOST_FUSION_ADAPT_STRUCT(point,(int, x) (int, y))
int main()
{
using namespace boost::spirit::qi;
rule<std::string::iterator,point()> value_rule = (int_ >> int_)[_val = _0];
}
------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and,
should the need arise, upgrade to a full multi-node Oracle RAC database
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Spirit-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
main.cpp
(text/x-c++src, 584 B)
#include <boost/spirit/include/qi.hpp>
#include <boost/fusion/adapted/struct/adapt_struct.hpp>
#include <boost/spirit/include/phoenix_fusion.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <string>
struct point
{
int x;
int y;
//point(const boost::fusion::vector2<int, int>& right); //why do I need to manually write this?
};
BOOST_FUSION_ADAPT_STRUCT(point,(int, x) (int, y))
int main()
{
using namespace boost::spirit::qi;
rule<std::string::iterator,point()> value_rule = (int_ >> int_)[_val = _0];
}