Boost logo

Boost :

Subject: Re: [boost] Interest check: constant input matching manipulator
From: Francois Barel (frabar666_at_[hidden])
Date: 2009-04-08 15:20:05


Eugene Wee wrote:
> Does anyone think that adding such a manipulator to Boost would be
> desirable? I expect the syntax to be along these lines (names and
> namespaces to be decided):
> std::cin >> match("a=") >> a;
> where a failure to match would place the input stream in a failed
> state. It would also be possible to use a std::basic_string instead of
> a string literal converted to a pointer to its first element as the
> argument.

Spirit2 already provides such functionality:

#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/qi_stream.hpp>
[...]
using namespace boost::spirit;
using namespace boost::spirit::qi;
std::cin >> match("a=" >> int_, a);

Regards,
François


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk