
13 Apr
2004
13 Apr
'04
12:42 a.m.
"Peter Dimov" <pdimov@mmltd.net> wrote in message news:000d01c420a3$e68d6240$1d00a8c0@pdimov2...
Thorsten Ottosen wrote: [snip]
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.
But isn't it possible to reject compiling the above example? It's really not what I would expect people to expect, especially since bind(write,_1)(s) differs. br Thorsten