Boost logo

Boost Users :

From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-04-25 17:09:47


AMDG

Robert Dailey wrote:
> Say I have a function as follows:
>
> *template< typename t_packet >
> void Subscribe( boost::function<void (t_packet const&)> 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.

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net