|
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?
Ryan
struct DataPoint
{
boost::optional<double> m_Time;
};
std::ostream & operator<<(std::ostream & stream, std::list<DataPoint>
const& points)
{
namespace bll = boost::lambda;
std::for_each(
points.begin(),
points.end(),
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 hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net