boost lambda phoenix problem: controlling std::for_each work any component container


i ran problem while cleaning adult aged code. function:



uint32_t adt::get_connectivity_data( std::vector< std::vector<uint8_t> > &output )
{
output.resize(chunks.size());
for(chunk_vec_t::iterator = chunks.begin(); < chunks.end(); ++it)
{
uint32_t success = (*it)->get_connectivity_data(output[it-chunks.begin()]);
}
relapse true;
}


what i am prying doing cleaning adult loop lambda countenance nonetheless fast got stranded accurately i pass repremand justification get_connectivity_data. get_connectivity_data takes std::vector anxiety fills data. cost contains std::vector any "chunk".



basically finish was roughly easier, cleaner shorter leave formula as-is.



edit:



so closest answer doubt i envisioned feeling this:



 std::for_each( chunks.begin(), chunks.end(), 
bind( &chunk_vec_t::value::type::get_connectivity_data,
_1,
output[ std::distance( _1, chunks.begn() ]
)
);


yet formula does compile, i finished modifications formula accumulate nonetheless i ran 2 issues:




  1. _ 1 intelligent ptr, std::distance work it, i cruise i indispensable &chunks[0] start

  2. since _ 1 intelligent pointer, i do: &chunk_vec_t::value_ type::valuetype::get_ connectivity_ information caused wreck vc9 compiler...



the answer per zip_ iterators looked good until i review some-more detected sole use, volume additional formula indispensable excellent (binding that, etc).



edit2:



i found an tolerable fortitude both low antipathetic syntax clear, i've posted here below.



std::transform(chunks.begin(), chunks.end(), back_inserter(tmp), boost::bind(&adtchunk::get_connectivity_data, _1) );


Comments

Popular posts from this blog

list macos calm editors formula editors

how i practical urls indicate .aspx pages asp.net deployed an iis? (preferably but iis)

jaxb - xjc - reworking generated typesafe enum category members