$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [Boost-users] if_then_else_return (boost::lambda) question
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-02-18 21:38:44
AMDG
Jonathan Leonard wrote:
> I'm fairly new to boost and have a little problem with 
> if_then_else_return. Can anyone tell me the problem with the following 
> short program?  [It seems that my 'thenBranch' and 'elseBranch' 
> functions are never called and if_then_else_return' always returns 
> true (as if the 'then' branch were called)].
The problem is that Boost.Lambda doesn't automatically call the 
boost::function.
Thus, evaluating the lambda expression returns a boost::function, 
boost::function
implicitly converts to bool.  (false iff the boost::function is empty.)
If you use boost::lambda::bind(MakeReturnTrue(thenBranch)), it should work.
> P.S. (A more general C++ q:  A little improvement I'd like to make is 
> to drop the ITERATORTYPE type argument from IfNotEndThenElseReturn and 
> use CONTAINERTYPE::iterator instead, but the compiler won't allow 
> that.  Anyone know why?).  Thanks again!
typename CONTAINERTYPE::iterator works for me.  Did you forget
typename?
In Christ,
Steven Watanabe