|
Boost Users : |
Subject: [Boost-users] doubt on lambda expression
From: Emanuele Rocci (rocciemanuele_at_[hidden])
Date: 2009-11-11 06:04:49
Hi AllI started playing with boost::lambda and I need some help or some clarification about itor 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 substitutefor writing a functor.
I expected the following result
value: 100interval: 20value: 200interval: 21
Instead I had the following
intervalfirst value: 1002020021
Why the strings "interval" and "first" are not written for each value and how can I achieve this?Kind RegardsMn
_________________________________________________________________
Più di 30 Web Radio: le trovi su Messenger
http://www.messenger.it/radioMessenger.aspx
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net