From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-04-12 10:36:16
Thorsten Ottosen wrote:
> "Peter Dimov" <pdimov_at_[hidden]> wrote in message
>> Thorsten Ottosen wrote:
>>> My point is that if the prototype was
>>> void square( int& );
>>> function< void(void) > f( int x )
>>> return bind( square, x*5 );
>>> should not compile.
>> Why should it not compile?
> consider instead
> void write_to( string& s )
> s += " foo";
> string s = "bar";
> bind( write_to, s )();
> cout << s; // won't print "bar foo"
That's how bind works. All arguments in "bind(write_to, s)" are copied,
including 'write_to'. If you make 'write_to' a stateful function object,
"bind(write_to, s)()" won't update 'write_to' either.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk