fork download
  1. #include <boost/spirit/include/qi.hpp>
  2. #include <boost/spirit/include/phoenix.hpp>
  3. #include <string>
  4.  
  5. int main() {
  6. std::string expression = "2<2";
  7. int result = 0;
  8.  
  9. using namespace boost::spirit::qi;
  10. using namespace boost::phoenix;
  11. bool success = parse(expression.begin(), expression.end(), int_[ref(result) = _1]);
  12.  
  13. if (success) {
  14. std::cout << "Result: " << result << std::endl;
  15. } else {
  16. std::cout << "Failed to parse expression" << std::endl;
  17. }
  18.  
  19. return 0;
  20. }
  21.  
Success #stdin #stdout 0.01s 5536KB
stdin
Standard input is empty
stdout
Result: 2