Boost logo

Boost Users :

Subject: Re: [Boost-users] nested bind() does not compile
From: Serguei Kolos (Serguei.Kolos_at_[hidden])
Date: 2010-07-15 05:23:35


Hi

Thanks, that works perfectly. In fact the bind documentation does mention
that function but I somehow overlooked it.

Cheers,
Sergei

Steven Watanabe wrote:
> AMDG
>
> Serguei Kolos wrote:
>> I'm wondering why the attached code which is using nested boost::bind()
>> does not compile on GCC ( I have tried 4.1 and 4.3). According to the
>> "bind" package documentation nested bind() calls are allowed.
>> To make it compile (and work!) it's necessary to add explicit cast to
>> the
>> result of the nested bind() call, like:
>>
>> boost::function<void ( void )> f =
>> boost::bind( wrapper, a, (boost::function<bool
>> (void)>)boost::bind( cb, p ), b );
>>
>> But that is something which I don't like.
>> Any ideas?
>
> Use boost::protect.
>
> The problem is that nested binds are handled specially:
>
> boost::bind( wrapper, a, boost::bind( c, p ), b );
> creates a function object that executes
> wrapper(a, c(p), b).
> what you want is
> wrapper(a, boost::bind( c, p ), b),
> so you have to write
> boost::bind( wrapper, a, boost::protect(boost::bind( c, p )), b );
>
> In Christ,
> Steven Watanabe
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


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