|
Boost : |
From: David B. Held (dheld_at_[hidden])
Date: 2002-07-09 19:48:20
"Sean Parent" <sparent_at_[hidden]> wrote in message
news:B950C3ED.12F58%sparent_at_adobe.com...
> I'm trying to use bind with for_each but I need a copy of the bound
> function object back after for_each. I've tried using boost::ref(f) but
> that just gives me a compiler error (CW 7.2) that the result type isn't
> defined (apparently on the wrapped reference.
> [...]
I can only assume that f below is a stateful functor, and you want f
after it's been modified by for_each? If so, the problem is that f
is stateful. ;) Apparently, stateful functors are bad, because there
is no guarantee that they won't get copied an arbitrary number of
times during use in an STL algorithm. So, the safe thing to do is
to only store references in a functor. Now that the actual data is
outside the functor anyway, you should have no trouble returning it.
Dave
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk