From: Jeffrey L. H. Jr. <jef...@gm...> - 2011-08-19 22:53:01
|
On Fri, Aug 19, 2011 at 3:20 PM, Marc Wäckerlin <ma...@wa...> wrote: > Hi there > > If I use a rule like: > > a>>b > > The attibute is a «tuple<A, B>» according to the documentation. > > How do I access the tupel in phoenix? According to tupel-documentation, I > should be able to access the first tupel part «a» using «get<0>()»: > > (a>>b)[qi::_1.get<0>()] > > But this fails, because «qi::_1» is not a tupel, but a: > > const struct boost::phoenix::actor<boost::spirit::argument<0> > > > So, how to get «a» (and «b») using phoenix in «(a>>b)[...]»? > #include <boost\spirit\home\phoenix\fusion\at.hpp> and then phoenix::at_c<qi::_1> should work. (Unfortunately, I don't think the above header is documented...yet :) [...] > Another example: > > Parse a line of string: > > std::string res; > Rule r = (+qi::char_)[phoenix::ref(res)=std::string(qi::_1.begin(), > qi::_1.end())]; > > Which does not work for the same reason, how to access the methods > «begin()» and «end()» of the matched vector? > This might help: http://www.boost.org/doc/libs/1_47_0/libs/spirit/phoenix/doc/html/phoenix/container.html - Jeff |