Hi All
I started playing with boost::lambda and I need some help or some clarification about it
or some hint to better understanding how does it work.

I have this piece of code

using namespace boost::lambda;
using boost::lambda::var;

int main(int argc, char** argv) {
   std::vector< int > myList;
   myList.push_back(100);
   myList.push_back(200);    
   int interval = 20;

   std::for_each( myList.begin(), myList.end(),
        (
        std::cout << "value: " << _1 << "\n",
        std::cout << "interval: " << var( interval ) << "\n",
        var( interval )++
        ));
}

I understood that writing a lambda expression would be a substitute
for writing a functor.

I expected the following result

value: 100
interval: 20
value: 200
interval: 21

Instead I had the following

intervalfirst value: 100
20
200
21

Why the strings "interval" and "first" are not written for each value and how can I achieve this?
Kind Regards
Mn



Screensaver, sfondi e scene: scarica i gadget di Messenger