How can I avoid “for” loops with an “if” condition inside them with C++?

前端 未结 13 1972
滥情空心
滥情空心 2021-01-30 03:31

With almost all code I write, I am often dealing with set reduction problems on collections that ultimately end up with naive \"if\" conditions inside of them. Here\'s a simple

13条回答
  •  野性不改
    2021-01-30 04:27

    for(auto const &x: myCollection) if(x == something) doStuff();
    

    Looks pretty much like a C++-specific for comprehension to me. To you?

提交回复
热议问题