How to get the index of a value in a vector using for_each?

前端 未结 10 691
[愿得一人]
[愿得一人] 2020-12-28 14:02

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          


        
10条回答
  •  爱一瞬间的悲伤
    2020-12-28 14:33

    maybe in the lambda function, pass it a int& instead of value int, so you'd have the address. & then you could use that to deduce your position from the first item

    would that work? i don't know if for_each supports references

提交回复
热议问题