Advantages of std::for_each over for loop

后端 未结 21 732
遥遥无期
遥遥无期 2020-11-29 15:23

Are there any advantages of std::for_each over for loop? To me, std::for_each only seems to hinder the readability of code. Why do then some coding

21条回答
  •  长情又很酷
    2020-11-29 16:06

    You can have the iterator be a call to a function that is performed on each iteration through the loop.

    See here: http://www.cplusplus.com/reference/algorithm/for_each/

提交回复
热议问题