Boost logo

Boost Users :

Subject: [Boost-users] [lambda][optional] Accessing an optional variable through lambda
From: Ryan McConnehey (mccorywork_at_[hidden])
Date: 2010-08-11 22:05:30

I'm trying to create a stream operator for a list of DataPoint objects.
I can't get the correct boost::lambda syntax to access what the optional
is containing. Could someone tell me what I'm doing wrong?


struct DataPoint
  boost::optional<double> m_Time;

std::ostream & operator<<(std::ostream & stream, std::list<DataPoint>
const& points)
  namespace bll = boost::lambda;
    stream << bll::bind(&boost::optional<double>::get,
bll::bind(&DataPoint::m_Time, bll::_1)) << bll::constant(" "));

    //Would prefer to do something like this
"*bll::bind(&DataPoint::m_Time, bll::_1)". This gives me quite the compile
    //error. Is there a way to use indirection or do I need to bind to
a optional method to get access?

  return stream;

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at