Opened 9 years ago
#8579 new Bugs
qi::as/qi::attr_cast<container_type> cannot be combined with some other parsers
Reported by: | Owned by: | Joel de Guzman | |
---|---|---|---|
Milestone: | To Be Determined | Component: | spirit |
Version: | Boost Development Trunk | Severity: | Problem |
Keywords: | Cc: |
Description
The following code should compile, but it doesn't. If you remove ">> qi::eoi" part from the rule, it compiles. There may be other parsers in place of qi::eoi which don't expose any attribute (qi::lit, qi::eps) - the code won't compile either. qi::as<vector_type> is redundant in this particular example, but it can do the work in a real program.
#include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/qi_match.hpp> #include <iostream> #include <sstream> #include <vector> namespace qi = boost::spirit::qi; int main() { typedef std::vector<int> vector_type; vector_type vector; std::istringstream is("11 22 33"); is >> std::noskipws >> qi::match(qi::as<vector_type>()[qi::int_ % ' '] >> qi::eoi, vector); // is >> std::noskipws >> qi::match(qi::attr_cast<vector_type>(qi::int_ % ' ') >> qi::eoi, vector); assert(is); for (auto value : vector) std::cout << value << ' '; }
Attachments (1)
Note:
See TracTickets
for help on using tickets.
Tentative fix patch