#include <iostream> #include <boost/spirit/include/qi.hpp> namespace qi = boost::spirit::qi; int main () { using qi::string; std::string input("a"); std::string::iterator strbegin = input.begin(); std::string p; bool ok = qi::phrase_parse(strbegin, input.end(), ((string("a") >> string("a")) | string("a")), qi::space, p); if (ok && strbegin == input.end()) { std::cout << p << std::endl; std::cout << p.size() << std::endl; } else { std::cout << "fail" << std::endl; std::cout << std::string(strbegin, input.end()) << std::endl; } } This program outputs aa. How is it possible? Input string is a. Parser should match aa or a. I have written string("a") only for testing operators.
The same is when using char_ instead of string.