Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-06-26 14:18:08

Misza wrote:
> I am having a very similar (I think) problem.
> Namely, I'm playing with the Spirit library. I started with
> the comma-separated-real-number-parser from the examples
> but wanted to use my own semantic action:
> void F (vector<double> &v, double x) {
> v.push_back(x);
> }
> the core function is:
> bool parse_numbers(char const* str, vector<double> &v) {
> return parse(str,
> real_p[bind<void>(&F,v,_1)] >>
> *(',' >> real_p[bind<void>(&F,v,_1)]),
> space_p).full;
> }

I've no idea what is the exact problem you're having, but one thing's for
sure: bind(&F, v, _1) stores a copy of v. I don't think that this is what
you want. Use ref(v). You don't need to use <void> with ordinary functions,
and the & in front of F isn't needed, too. bind(&vector<double>::push_back,
&v, _1) is also possible.

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at