Breaking in std::for_each loop

前端 未结 7 1434
南方客
南方客 2021-01-01 10:37

While using std::for_each algorithm how do I break when a certain condition is satisfied?

7条回答
  •  南方客
    南方客 (楼主)
    2021-01-01 11:09

    As already shown by others it is only achievable with workarounds that IMHO obfuscate the code.

    So my suggestions is to change the for_each into a regular for loop. This will make it more visible to others that you are using break (and maybe even continue).

提交回复
热议问题