|
Boost Users : |
From: Stephen Torri (storri_at_[hidden])
Date: 2007-05-18 21:00:46
I have a loop which I am trying to convert to using a boost::lambda
function.
typedef std::vector< boost::shared_ptr<Verification_Type_Info> >
Append_Data_t;
Append_Data_t m_data;
... Used in ....
boost::uint32_t new_indent_limit = 2;
for ( Append_Data_t::const_iterator cpos = m_data.begin();
cpos != m_data.end();
++cpos )
{
output << (*cpos)->to_String ( new_indent_limit );
}
Now I figure out that I can use the std::for_each algorithm for the
iteration. I just need to supply the beginning and end forward iterators
for m_data. What has me confused, since the lambda example page is not
clear to me, is how do I call the member function 'to_String' for each
Vertification_Type_Info object in the m_data container?
My idea was to do:
std::for_each ( m_data.begin(),
m_data.end(),
output << (_1 ->* &Verification_Type_Info::to_String) ( new_indent_limit ) );
This idea does not compile. I get errors about trying to send a
boost::lambda::operator->* to std::stringstream variable 'output'. If a
&_1 will give me the address of the object in the container at a
position will *_1 dereference the pointer at that position?
Stephen
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