#include #include #include #include int main() { using namespace std; // parsing parentheses that may or may contain integers or one of a couple other things using namespace boost::spirit::qi; rule nulltok = boost::spirit::qi::string("novalue"); rule othertok = boost::spirit::qi::string("somethingelse"); boost::optional result; std::string in("(novalue)"); auto beg = in.begin(); auto end = in.end(); phrase_parse(beg, end, '(' > ((int_ | nulltok) ^ othertok) > ')', // <<<< uninit instead of "not present" ascii::space, result); cout << result << "\n"; }