
Thanks, I changed it to a lazy function as suggested, and then it works. Just for the record: struct Ipv4Address : qi::grammar<const char *, Ipv4()> { Ipv4Address() : Ipv4Address::base_type(start) { start = ( octet >> qi::lit('.') >> octet >> qi::lit('.') >> octet >> qi::lit('.') >> octet ) [ qi::_val = phx::bind(&make_ipv4, qi::_1, qi::_2, qi::_3, qi::_4 ) ] ; } qi::rule<const char *, Ipv4()> start; } ipv4_address; On Tue, Jul 3, 2012 at 2:29 PM, Igor R <boost.lists@gmail.com> wrote:
Sorry for not providing the simplest possible code to reproduce my problem, but I'm still new to spirit, I think I will miss some details in the conversion.
I tried add the inclusion you suggested, but it did not help.
Sorry, although it works for boost::tuple, it won't work for your Ipv4 struct... But a simple workaround can solve this issue: in Ipv4Address grammar change attribute to boost::tuple<uint8_t, uint8_t, uint8_t, uint8_t>, and in your parse() function use tuple type as temporary, then copy it to Ipv4 argument (you use a temporary anyway). Like this: bool parse(const const_string& s, Ipv4& i) { boost::tuple<uint8_t, uint8_t, uint8_t, uint8_t> _i; const char * iter = s.begin(); bool r = qi::parse(iter, s.end(), ipv4_address, _i);
if( !r || iter != s.end() ) return false;
i = Ipv4(_i); return true; } _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users