|
Boost Users : |
Subject: Re: [Boost-users] Why is cref required in this nested bind example?
From: Chris Stankevitz (chrisstankevitz_at_[hidden])
Date: 2012-12-05 13:58:41
On Tue, Dec 4, 2012 at 4:48 PM, Nathan Crookston
<nathan.crookston_at_[hidden]> wrote:
>> //bind(b, bind(a));//*1
>> bind(b, cref(bind(a)));//*2
>
> In short, *1 is evaluating a()
Thank you. This surprises me as I thought boost::bind returned an
object of type boost::function. I need to understand this better and
am about to go read more on this.
> It would be more idiomatic to use protect:
>
> bind(b, boost::protect(bind(a)))
I made the change, thank you. Hopefully when I understand better what
boost::bind is doing (i.e. not returning a boost::function) it will be
obvious why I need boost::protect. My guess is that boost::protect
converts whatever boost::bind does return into a boost::function.
Thanks again,
Chris
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