Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-10-19 08:27:11


Chris Weed wrote:
> Hi,
> I can get the following code to compile and it prints
> 3 2
> 5
> but I don't quite understand why it doesn't print
> 2 3
> 5
> or how to get it to do so. I thought since it is binding 2 to _1, this
> would bind it to the a argument.

Calling bind( fx, _1, 2 ) with 3 will put the '3' in the _1 and pass the 2
intact, the result is fx( 3, 2 ). bind( fx, _1, _1 ) will call fx( 3, 3 ).
bind( fx, 2, _1 ) calls fx( 2, 3 ). bind( fx, 4, 5 ) calls fx( 4, 5 ).

Does it make sense now? bind is not an interpreter with a mini-language
("bind the second argument to 2"), you just pass the argument values, and _1
is substituted with the first input argument (3 in your case).


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