Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define BOOST_SPIRIT_USE_PHOENIX_V3 1
- #include <string>
- #include <iostream>
- #include <boost/phoenix/core.hpp>
- #include <boost/spirit/include/qi_core.hpp>
- #include <boost/spirit/include/qi_lit.hpp>
- namespace qi = boost::spirit::qi;
- namespace phoenix = boost::phoenix;
- bool parse_counter_placeholder(std::string::const_iterator& it, std::string::const_iterator end, unsigned int& width)
- {
- return qi::parse
- (
- it, end,
- (
- qi::uint_[phoenix::ref(width) = qi::_1_type()]
- )
- );
- }
- int main(int argc, char* argv[])
- {
- std::string str;
- if (argc >= 2)
- str = argv[1];
- else
- str = "5N";
- unsigned int width = 0;
- std::string::const_iterator it = str.begin();
- bool res = parse_counter_placeholder(it, str.end(), width);
- std::cout << "res = " << res << ", width = " << width << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement