
Aha. boost::ref is exactly what I needed. Thank you so much for your consise and informative reply! "Peter Dimov" <pdimov@mmltd.net> wrote in message news:007701c61515$20de1680$6407a8c0@pdimov2...
Will wrote:
Hi, I'm looking for a general technique for binding signals with varying signatures together. Obviously i can create custom functions for any specific case, but i'm wondering if boost::bind could be used to help out here?
i.e.
boost::signal1<void, const char *> sig1; boost::signal0<void> sig2;
void bing() { std::cout << "bing" << std::endl; }
// connect sig1 to sig2 such that calling sig1 will invoke sig2 // ... <- how do i do this?
// connect sig2 to some function sig2.connect(&bing);
sig1.connect( boost::bind( boost::ref( sig2 ) ) );
should work. In general, boost::bind( f, a1, a2... ) will call f( a1, a2... ), so bind( f ) will simply call f(); the argument will be ignored (because there is no _1 in the bound argument list).
Another (clearer) example of bind ignoring an input argument is bind( f, _2 ), which only passes the second argument and ignores the first.
The ref() is needed since sig2 is noncopyable.
// call the signal sig1("some string");