
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Sebastian Weber Sent: Tuesday, November 07, 2006 12:41 PM To: boost-users@lists.boost.org Subject: [Boost-users] [lambda] if-then-else construct gets broken bylambda-lib
I'm trying to store a reference to a function depending upon a condition within a function object like this:
boost::function< double (std::size_t) > wf = (sIndex < m_maxIndex+1) ? ( boost::lambda::bind(boost::ref(m_cf), sDeg, boost::lambda::_1) ) : ( boost::ref(*m_wf) );
[Nat] Does it work better if the 'else' clause is something more like: ( boost::lambda::bind(boost::ref(*m_wf)) ) ? This is a wild guess, but boost::ref() isn't by itself a lambda bind expression -- is it? Both halves of the ternary operator are convertible to boost::function -- but they're not the same type. I don't know whether two different boost::lambda::bind expressions are going to be compatible either. You may have to explicitly instantiate boost::function objects on both sides of the : -- which would end up being less terse than writing the if/else statement. But it seems worth a try.