$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [Boost-users] [phoenix] or [lamdba] Operating on containers of smart pointers.
From: Raindog (raindog_at_[hidden])
Date: 2008-10-23 15:28:45
Steven Watanabe wrote:
> AMDG
>
> Raindog wrote:
>> I ran into a problem while cleaning up some old code. What I wanted 
>> to do was replace explicit for loops with some stl algorithms or 
>> BOOST_FOREACH. Below is the original function:
>>
>> |//in header file:
>> ..snip
>> typedef std::vector<Loki::SmartPtr<ADTChunk> > chunk_vec_t
>> chunk_vec_t chunks;
>> ..snip
>>
>> //in source file:
>> uint32_t ADT::get_connectivity_data( std::vector< 
>> std::vector<uint8_t> > &output )
>> {
>>        output.resize(chunks.size());
>>        for(chunk_vec_t::iterator it = chunks.begin(); it < 
>> chunks.end(); ++it)
>>        {
>>                uint32_t success = 
>> (*it)->get_connectivity_data(output[it-chunks.begin()]);
>>        }
>>        return TRUE;
>> }
>
> I think what you want is a two argument version of for_each.
>
Thanks Steven, what I did actually instead was make a few modifications 
to the functions involved and came up with this as a replacement of the 
explicit for loop.
std::transform(chunks.begin(), chunks.end(), back_inserter(tmp), 
boost::bind(&ADTChunk::get_connectivity_data, _1) );