Skip to content

Instantly share code, notes, and snippets.

@Tristramg
Created February 23, 2011 10:00
Show Gist options
  • Save Tristramg/840232 to your computer and use it in GitHub Desktop.
Save Tristramg/840232 to your computer and use it in GitHub Desktop.
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <iostream>
using namespace boost::spirit::qi;
using namespace boost::phoenix;
typedef std::string::iterator Iterator;
int main(int, char**){
int year, month, day;
rule<Iterator> date = int_[ref(day) = _1] >> '/'
>> int_[ref(month) = _1] >> '/'
>> int_[ref(year) = _1];
std::string str = "10/12/2010";
Iterator begin = str.begin();
Iterator end = str.end();
parse(begin, end, date);
std::cout << year << month << day << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment