From: Victor A. Wagner, Jr. (vawjr_at_[hidden])
Date: 2002-07-10 00:08:37
good, bad, or otherwise, for_each returns a copy of the functor.
we aren't questioning any algorithm, just for_each, and it IS defined.
I think, perhaps, you've read more into 'hazards of stateful functors' than
At Tuesday 2002/07/09 17:48, you wrote:
>"Sean Parent" <sparent_at_[hidden]> wrote in message
> > 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.
>Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Victor A. Wagner Jr. http://rudbek.com
PGP RSA fingerprint = 4D20 EBF6 0101 B069 3817 8DBF C846 E47A
PGP D-H fingerprint = 98BC 65E3 1A19 43EC 3908 65B9 F755 E6F4 63BB 9D93
The five most dangerous words in the English language:
"There oughta be a law"
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk