C++ STL: Which method of iteration over a STL container is better?

后端 未结 9 1009
轻奢々
轻奢々 2020-12-09 11:43

This may seem frivolous to some of you, but which of the following 2 methods of iteration over a STL container is better? Why?



        
9条回答
  •  抹茶落季
    2020-12-09 12:14

    If you don't mind a (very?) small loss of efficiency, i'd recommend using Boost.Foreach

    BOOST_FOREACH( Elem& e, elemVec )
    {
        // Your code
    }
    

提交回复
热议问题