Hi,
I've recently started using boost lambda and thought I'd try and use it in places where it will/should make things easier to read.
I have some code similar to the following
std::vector< X * > v;
for ( int i = 0 ; i < 20 ; ++i )
v.push_back( new X() );
and later on, to delete it...
std::for_each( v.begin(), v.end(), boost::lamda::delete_ptr() );
Which neatly tidies up.
However, I thought I'd have a go at "lambda-ising" the population of the vector using lambda... That's then the fireworks started...
I tried..
std::generate_n( v.begin(), 20, _1 = new X() );
but this threw all kinds of compiler errors.
Any ideas which is the best "lambda" way to achieve this.
Thx Mark.