Boost logo

Boost Users :

From: Stuart Dootson (stuart.dootson_at_[hidden])
Date: 2006-11-07 13:58:01


On 11/7/06, Sebastian Weber <sebastian.weber_at_[hidden]> wrote:
> Hello everybody!
>
> 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) );
>

<snip>

>
> Greetings,
>
> Sebastian Weber
>

Try this -

boost::function< double (std::size_t) > wf = (sIndex < m_maxIndex+1) ?
boost::function< double (std::size_t) >(
boost::lambda::bind(boost::ref(m_cf), sDeg, boost::lambda::_1) ) ) : (
boost::ref(*m_wf) );

i.e. make sure the first expression is explicitly a boost::function<
double (std::size_t) >, as the second is convertible to that.

Stuart Dootson


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