29 Feb
2008
29 Feb
'08
10:21 a.m.
Hi, bind makes copies of the given parameters and operates on them. If you want bind to operate on a reference of the given object, you should use boost::ref. struct Bar { Bar( Foo& foo_ ) : foo( foo_ ) { } void operator()( const char* s_ ) { bind<void>(boost::ref(foo), _1, 42)(s_); } Foo& foo; }; This results in: $ ./a.out Hallo, 42 Greetings, Stefan On Do, 2008-02-28 at 21:04 +0100, Olaf Peter wrote:
Thanks a lot, the wrong return type was stupid ...
struct Bar {
Bar( Foo& foo_ ) : foo( foo_ ) { }
void operator()( const char* s_ ) { bind<void>(foo, _1, 42)(s_); }
Foo& foo; };
That compiles for me in VC++ 8
yes, but I do not get the expected output, I was not carefully enough?
$ ./bind X, 11