The documentation says that the attribute of two composited rules (a >> b) should be tuple if both A and B are used.
Assuming this I tried to read out the first attribute of such a tuple. But it fails:
(I try to store the parsed integer in 'i')
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_object.hpp>
template <typename ForwardIterator> class TestGrammar
: public boost::spirit::qi::grammar<ForwardIterator, boost::spirit::ascii::space_type>
{
boost::spirit::qi::rule<ForwardIterator, boost::spirit::ascii::space_type> foo_;
public:
TestGrammar( void ) : TestGrammar::base_type( foo_ )
{
int i;
foo_ = ((boost::spirit::qi::int_ >> boost::spirit::qi::float_)
[boost::phoenix::ref(i) = boost::phoenix::at_c<0>(boost::spirit::_1)]);
}
};
int main( void )
{
TestGrammar<std::string::iterator> g;
return 0;
}
Writing:
foo_ = ((boost::spirit::qi::int_ >> boost::spirit::qi::float_)
[boost::phoenix::ref(i) = boost::spirit::_1]);
will always work though as long as A is an int.
Changing types back and forth and writing custom rules revealed that the attribute of (a >> b) will always be A regardless of what B is.
Even