
20 Feb
2008
20 Feb
'08
7:49 p.m.
Richard wrote:
[Please do not mail me a copy of your followup]
boost-users@lists.boost.org spake the secret code <019801c8721d$e1612fc0$6407a80a@pdimov2> thusly:
It is impossible to overload && in such a way so that in e1 && e2, e2 is not evaluated when e1 is false. But it's possible to overload f && g so that in (f && g)(x) :- f(x) && g(x), g(x) is not evaluated when f(x) is false.
I guess I'm still a little lost... why does it work for f && g and not e1 && e2? Is it because f and g are functors and don't evaluate their expressions until their operator() is called?
Yes, and because (f && g) returns another function object, whose operator() can first evaluate f(x) then decide whether to evaluate g(x). Jeff Flinn