I have a loop which I am trying to convert to using a boost::lambda
function.
typedef std::vector< boost::shared_ptr >
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