Breaking in std::for_each loop

前端 未结 7 1443
南方客
南方客 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:13

    You can't do it, unless you throw an exception, which is not a good idea because you don't do flow control with exceptions.

    Update: apparently Boost has a for_each_if that might help, but you're not using Boost.

提交回复
热议问题