On Fri, Apr 25, 2008 at 4:09 PM, Steven Watanabe
AMDG
Robert Dailey wrote:
Say I have a function as follows:
*template< typename t_packet > void Subscribe( boost::function
func ) { // gSignal is a boost::signal somewhere. Assume valid. gSignal.connect( func ); }* And in some other function, I invoke Subscribe() as follows: * void MyCallback( WalkPacket const& p ) { }
void MainTest() { Subscribe( &MyCallback ); }*
The code above will actually not compile, since the template parameter t_packet cannot be deduced. Is there a way I can make the template deduction work?
You can construct a boost::function at the call site explicitly rather than relying on the implicit conversion.
Alternately you can provide an overload of Subscribe for function pointers.
That kind of defeats the purpose. I'm trying to make Subscribe figure out the type of the packet itself to avoid having to explicitly say "I'm subscribing for a WalkPacket" when the signature of the slot already has this information. The current implementation requires this syntax: Subscribe<WalkPacket>( &walkPacketCallback );