Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<vector>
- #include<boost/spirit/include/qi.hpp>
- namespace sqi = boost::spirit::qi;
- int main(){
- std::string const v_str = "AA BB CC";
- std::vector<std::string> v;
- auto it = begin(v_str);
- bool r = sqi::phrase_parse(it, end(v_str), (*sqi::lexeme[+sqi::char_("A-Z")]), sqi::space, v);
- assert( v.size() == 3 and v[2] == "CC" );
- }
- std::string const v_str = "3 AA BB CC";
- std::vector<std::string> v;
- auto it = begin(v_str);
- bool r = sqi::phrase_parse(it, end(v_str), sqi::int_[([&](int i){v.reserve(i);})] >> (*sqi::lexeme[+sqi::char_("A-Z")]), sqi::space, v);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement