1 | #include <boost/fusion/include/adapt_struct.hpp>
|
---|
2 | #include <boost/spirit/include/qi.hpp>
|
---|
3 |
|
---|
4 | #include <iostream>
|
---|
5 | #include <list>
|
---|
6 |
|
---|
7 | namespace qi = boost::spirit::qi;
|
---|
8 |
|
---|
9 | // Error
|
---|
10 | struct foo
|
---|
11 | {
|
---|
12 | std::list<int> l;
|
---|
13 | };
|
---|
14 |
|
---|
15 | BOOST_FUSION_ADAPT_STRUCT(
|
---|
16 | foo,
|
---|
17 | (std::list<int>, l)
|
---|
18 | )
|
---|
19 |
|
---|
20 | // Using this instead of the above it works
|
---|
21 | /* struct foo
|
---|
22 | : std::list<int> {}; */
|
---|
23 |
|
---|
24 | int main(int argc, char** argv) {
|
---|
25 | std::string input("1,2,3");
|
---|
26 |
|
---|
27 | // Error
|
---|
28 | qi::rule<std::string::iterator, foo()> rule =
|
---|
29 | qi::int_ % ","
|
---|
30 | ;
|
---|
31 |
|
---|
32 | // Works, should be equivalent
|
---|
33 | /* qi::rule<std::string::iterator, foo()> rule =
|
---|
34 | qi::int_ >> *("," >> qi::int_)
|
---|
35 | ; */
|
---|
36 |
|
---|
37 | // Also works
|
---|
38 | /* qi::rule<std::string::iterator, foo()> rule =
|
---|
39 | qi::int_ % ","
|
---|
40 | >> qi::eps
|
---|
41 | ; */
|
---|
42 |
|
---|
43 | std::string::iterator iter = input.begin();
|
---|
44 | bool r = qi::parse(iter, input.end(), rule);
|
---|
45 |
|
---|
46 | std::cout << (r ? "true" : "false") << std::endl;
|
---|
47 | }
|
---|