|
Boost Users : |
Subject: Re: [Boost-users] nested bind() does not compile
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-07-15 11:07:46
AMDG
Robert Jones wrote:
> On Wed, Jul 14, 2010 at 7:30 PM, Steven Watanabe <watanabesj_at_[hidden]>wrote:
>
>> 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 );
>
> I know I'm being really dim here, but I have a strange mental block
> about protect, so for the hard-of-thinking can you explain the difference
> between
>
> boost::bind( wrapper, a, boost::bind( c, p ), b );
>
> and
>
> boost::bind( wrapper, a, boost::protect(boost::bind( c, p )), b );
>
The usual behavior of nested binds is to evaluate them
all at once like: wrapper(a, c(p), b). Note that this means
that when evaluating a bind, we first recurse into all nested
binds. protect prevents this. A bind object
that has been protected is treated like any other
argument giving: wrapper(a, boost::protect(boost::bind( c, p )), b)
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