Ticket #12473: optional_issue_reduced.cpp

File optional_issue_reduced.cpp, 798 bytes (added by edaskel@…, 6 years ago)

reduced testcase

Line 
1#include <iostream>
2#include <boost/spirit/include/qi.hpp>
3#include <boost/optional.hpp>
4#include <boost/optional/optional_io.hpp>
5
6int main() {
7 using namespace std;
8
9 // parsing parentheses that may or may contain integers or one of a couple other things
10
11 using namespace boost::spirit::qi;
12 rule<string::iterator> nulltok = boost::spirit::qi::string("novalue");
13 rule<string::iterator> othertok = boost::spirit::qi::string("somethingelse");
14
15 boost::optional<int> result;
16 std::string in("(novalue)");
17 auto beg = in.begin();
18 auto end = in.end();
19 phrase_parse(beg, end,
20 '(' > ((int_ | nulltok) ^ othertok) > ')', // <<<< uninit instead of "not present"
21 ascii::space,
22 result);
23 cout << result << "\n";
24}