Boost logo

Boost Users :

From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-05-14 15:11:33


AMDG

gfsdjkgf_at_[hidden] wrote:
>> Wrap Handler in boost::protect. For lambda use boost::lambda::protect
>>
>> bind(&Test2<Handler_t>, boost::protect(Handler))();
>>
>>
>>
> Sorry, but this does not work.
>

I see. The explicit template parameter needs to be updated too.

#include <boost/bind.hpp>
#include <boost/bind/protect.hpp>
using boost::bind;

//#include <boost/lambda/bind.hpp>
//using boost::lambda;

template<class Handler_t>void Test2(Handler_t Handler)
{
}

template<class Handler_t>void Test1Impl(Handler_t Handler)
{
    bind(&Test2<Handler_t>, Handler)();
}

template<class Handler_t>void Test1(Handler_t Handler)
{
    Test1Impl(boost::protect(Handler));
}

void TestFunc(int i)
{
}

int main()
{
    Test1(bind(TestFunc,0));
}

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