Get index in C++11 foreach loop

后端 未结 5 879
太阳男子
太阳男子 2020-12-28 12:55

Is there a convenient way to get the index of the current container entry in a C++11 foreach loop, like enumerate in python:

for idx, obj in enu         


        
5条回答
  •  旧时难觅i
    2020-12-28 13:56

    If you need the index then a traditional for works perfectly well.

    for (int idx=0; idx

提交回复
热议问题