Boost logo

Boost Users :

Subject: Re: [Boost-users] problems with boost bind and boost thread
From: Gabriel Redner (gredner_at_[hidden])
Date: 2012-03-22 09:45:30



The gist of the problem is that nested binds do not work the way you
expect. For an explanation, see:


On Thu, Mar 22, 2012 at 4:56 AM, Marco <marco.schumann_at_[hidden]> wrote:
> Hi,
> I have problems with the attached code (test.cpp, extracted from the
> original class only with the relevant code).
> The member template  constructor of CCycleThread takes an argument and
> passes this to boost bind. The binding is to a another member template
> method which is the thread function for boost thread:
> boost::thread(boost::bind(&CCycleThread::execute<T>,this,t)
> The template parameter type is deduced by the argument type passed by the
> user.
> If the type is an ordinary function the code works fine. If the argument
> itself is another boost bind object the compilation fails!
> I tested the following within the constructor:
> auto test = boost::bind(&CCycleThread::execute<T>,this,t) // -> ok
> test(); // -> compile error
> The call of the operator() of the bind object is the problem.
> Interestingly, if one binding is boost::bind and the other one is std::bind
> the code works.
> Any ideas what's the problem? How can I fix this? Using std and boost bind
> is more a hack than a real solution :/
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at