On Thu, Jun 21, 2012 at 9:52 PM, Chris Foster <[email protected]> wrote:
> On Thu, Jun 21, 2012 at 7:39 PM, Stefan Stavrev <[email protected]> 
> wrote:
>> Then you would call:
>>
>> parallel_image (boost::bind (over_RAB (R, A,  B, roi) ), R, roi, nthreads)
>
> The trick is to partially apply over_RAB, that is, only bind some of
> the arguments.  The partial application syntax when using boost::bind is
> as follows:
>
> boost::bind(over_RAB, R, A, B, _1)

I should also point out that _1 is a placeholder which is defined when you
include boost/bind.hpp; _1 represents where the first argument of the
resulting function object will be inserted into the argument list of
over_RAB.  (If you look behind the scenes you will see that _1 is an
instance of a tag struct, defined in boost/bind/placeholders.hpp)

More generally you can have things like

boost::bind(foo, _1, 1337, _2)

which binds 1337 to the middle argument of a function foo of three
arguments, and

boost::bind(bar, _2, _1)

which reverses the order of arguments to bar.  It's very flexible and
nice.

~Chris
_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to