I have the following code (compiler: MSVC++ 10):
std::vector data;
data.push_back(1.0f);
data.push_back(1.0f);
data.push_back(2.0f);
// lambda
Following the standard convention for C and C++, the first element has index 0, and the last element has index size() - 1.
So you have to do the following;-
std::vector data;
int index = 0;
data.push_back(1.0f);
data.push_back(1.0f);
data.push_back(2.0f);
// lambda expression
std::for_each(data.begin(), data.end(), [&index](float value) {
// Can I get here index of the value too?
cout<<"Current Index :"<