Boost logo

Boost :

From: Powell, Gary (powellg_at_[hidden])
Date: 2004-02-03 11:30:14

I ran into the following problem. I have an algorithm which looks like:

template<typename in_t, typename out_t>
void Alg (in_t in, in_t inend, out_t out) {
  for (; in != inend; in++, out++)

Now if I want to call this algorithm more than once, it would be convenient
to pass out by ref, so it would be incremented:

Alg (v.begin(), v.end(), boost::ref (out))
that is, pass a reference to some kind of output iterator

this fails, because boost::ref doesn't have operator++ defined for

My question is, should boost::ref forward operators like ++ so that this
would work?
Gary Replied:
I think you need a different tool, either FC++ or Lambda. "ref()" is just a simple wrapper to make something act like a reference. What you need is the whole operator set and Lambda and FC++ have those.

  Alg(v.begin(), v.end(), boost::lambda::var(out) );

Should work as you want.


Boost list run by bdawes at, gregod at, cpdaniel at, john at