Boost logo

Boost Users :

From: Nat Goodspeed (ngoodspeed_at_[hidden])
Date: 2006-11-07 12:50:57


> -----Original Message-----
> From: boost-users-bounces_at_[hidden] [mailto:boost-users-
> bounces_at_[hidden]] On Behalf Of Sebastian Weber
> Sent: Tuesday, November 07, 2006 12:41 PM
> To: boost-users_at_[hidden]
> 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.


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