On 19/05/07, Stephen Torri
On Sat, 2007-05-19 at 09:34 -0400, Nat Goodspeed wrote:
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Stephen Torri Sent: Friday, May 18, 2007 9:01 PM To: boost-users Subject: [Boost-users] Converting loop to using boost::lambda where containers has boost::shared_ptrs
My idea was to do:
std::for_each ( m_data.begin(), m_data.end(), output << (_1 ->* &Verification_Type_Info::to_String) ( new_indent_limit ) );
[Nat] I think the construct you want will look more like (untested):
std::for_each(m_data.begin(), m_data.end(), output << boost::bind(&Verification_Type_Info::to_String, _1, new_indent_limit));
Its close but not quite. I get an error message that _1 is ambiguous
Append_Frame.cpp:48: error: reference to '_1' is ambiguous /usr/include/boost/lambda/core.hpp:69: error: candidates are: const boost::lambda::placeholder1_type& boost::lambda::<unnamed>::_1 /usr/include/boost/bind/placeholders.hpp:54: error: boost::arg<1> <unnamed>::_1
Stephen
Nat's using Boost.Bind, not the bind in Boost.Lambda - they both
define _1 as a placeholder, so they clash...
Using bind from Boost.Lambda, you'll need nested binds to cope with shared_ptr:
using namespace boost::lambda;
std::for_each(m_data.begin(), m_data.end(),
output << bind(&Verification_Type_Info::to_String,
bind(boost::shared_ptr