[Lambda] nitty gritty detail...?

From Bjorn Karlsson's book, P297...
int i; int value = 12; var(i) = ( if_then_else_return( _1>=10, constant(10),_1) )(value); Why does the assignment LHS need to be wrapped in var()? Thanks in advance - Rob.

AMDG On 03/31/2011 08:29 AM, Robert Jones wrote:
From Bjorn Karlsson's book, P297...
int i; int value = 12; var(i) = ( if_then_else_return( _1>=10, constant(10),_1) )(value);
Why does the assignment LHS need to be wrapped in var()?
Because operator= must be a member function. In Christ, Steven Watanabe

On Thu, Mar 31, 2011 at 4:47 PM, Steven Watanabe
AMDG
On 03/31/2011 08:29 AM, Robert Jones wrote:
From Bjorn Karlsson's book, P297...
int i; int value = 12; var(i) = ( if_then_else_return( _1>=10, constant(10),_1) )(value);
Why does the assignment LHS need to be wrapped in var()?
Because operator= must be a member function.
Nope, still not getting it! Stop me when I err... if_then_else_return(...) defines a unary functor it_then_else_return(...)( value) evaluates that functor, and returns what? Some type of integer I think? So doesn't the assignment simply perform assignment of an integer, by copy? And that doesn't need operator= to a member of anything? Thanks - R.

AMDG On 03/31/2011 11:27 AM, Robert Jones wrote:
On Thu, Mar 31, 2011 at 4:47 PM, Steven Watanabe
wrote: On 03/31/2011 08:29 AM, Robert Jones wrote:
From Bjorn Karlsson's book, P297...
int i; int value = 12; var(i) = ( if_then_else_return( _1>=10, constant(10),_1) )(value);
Why does the assignment LHS need to be wrapped in var()?
Because operator= must be a member function.
Nope, still not getting it! Stop me when I err...
if_then_else_return(...) defines a unary functor it_then_else_return(...)( value) evaluates that functor, and returns what?
Some type of integer I think?
Yes.
So doesn't the assignment simply perform assignment of an integer, by copy? And that doesn't need operator= to a member of anything?
Oh, I see. As written, the code doesn't make much sense, so my mind automatically translated it into (var(i) = if_then_else_return( _1>=10, constant(10),_1) )(value); In Christ, Steven Watanabe
participants (2)
-
Robert Jones
-
Steven Watanabe