Boost logo

Boost Users :

From: Sebastian Weber (sebastian.weber_at_[hidden])
Date: 2006-11-07 12:41:04


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) );

However, this does not compile. The error message is:

error: no match for ternary 'operator?:' in '(sIndex <
(((boost::cor_cm_iterator4<RandomGenerator,
Graph>*)this)->boost::cor_cm_iterator4<RandomGenerator,
Graph>::m_maxIndex + 1)) ?
boost::lambda::bind(boost::ref(((boost::cor_cm_iterator4<RandomGenerator, Graph>*)this)->boost::cor_cm_iterator4<RandomGenerator, Graph>::m_cf), sDeg, boost::lambda::<unnamed>::_1) : boost::ref((*((boost::cor_cm_iterator4<RandomGenerator, Graph>*)this)->boost::cor_cm_iterator4<RandomGenerator, Graph>::m_wf))'

But the lengthy code

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

compiles fine. Any idea? How can lambda eat up the ? : construct? How do
I prevent that?

My system is a ubunut edgy which means, I have g++ 4.1 and use boost
1.33.1.

Greetings,

Sebastian Weber


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