> qi::double_ v.s. >> qi::double_
I want to parse the following string
"***: @a_-091 , *** 1"
to a struct defined as
using type = boost::fusion::vector<char, int, double>;
When the parser
*qi::omit[qi::char_ - '@'] >> '@' >> qi::char_ >> '_' >> qi::int_ >> *qi::omit[qi::char_ - qi::digit] >> qi::double_
is used, the result is OK. However, the result is totally different with the following parser
*qi::omit[qi::char_ - '@'] >> '@' >> qi::char_ >> '_' >> qi::int_ >> *qi::omit[qi::char_ - qi::digit] > qi::double_
The following is the sample code.
#include <vector>
#include <sstream>
#include <iostream>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/qi_match.hpp>
#include <boost/fusion/include/io.hpp>
using type = boost::fusion::vector<char, int, double>;
int main() {
std::istringstream istr{
"***: @a_-091 , *** 1"
};
std::vector<type> data;
namespace qi = boost::spirit::qi;
istr >> std::noskipws >> qi::match(*(
*qi::omit[qi::char_ - '@'] >> '@' >> qi::char_ >> '_' >> qi::int_ >> *qi::omit[qi::char_ - qi::digit] > qi::double_
), data);
// istr >> std::noskipws >> qi::match(*(
*qi::omit[qi::char_ - '@'] >> '@' >> qi::char_ >> '_' >> qi::int_ >> *qi::omit[qi::char_ - qi::digit] >> qi::double_
), data);
for (size_t i = 0; i != data.size(); ++i) {
std::cerr << data[i] << "\n";
}
return 0;
}
PS: The problem has been solved by the link proved by cv_and_he in the comment. It is caused by the mixed usage of ">>" (the sequence parser) and ">" (the expectation parser).