Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include<vector>
  2. #include<boost/spirit/include/qi.hpp>
  3. namespace sqi = boost::spirit::qi;
  4. int main(){
  5. std::string const v_str = "AA BB CC";
  6. std::vector<std::string> v;
  7. auto it = begin(v_str);
  8. bool r = sqi::phrase_parse(it, end(v_str), (*sqi::lexeme[+sqi::char_("A-Z")]), sqi::space, v);
  9. assert( v.size() == 3 and v[2] == "CC" );
  10. }
  11.  
  12. std::string const v_str = "3 AA BB CC";
  13. std::vector<std::string> v;
  14. auto it = begin(v_str);
  15. 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