C++ standard library - when should I use it and when shouldn't I?

前端 未结 8 573
离开以前
离开以前 2020-12-29 19:23

I was wondering how often people actually use much of the standard c++ library, particularly the stuff in the and

8条回答
  •  情话喂你
    2020-12-29 19:57

    Just about everyone using C++ uses the STL, especially . You really don't want to have to write sorting functions yourself; you'll just end up making mistakes, and in the end the performance will probably be worse.

    Whether or not there are performance gains obviously depends on what you are comparing to. In general though, using the STL algorithms is typically faster than writing your own functions -- unless you happen to have a particular trick that applies to your use case that could give you the edge. If you just write a standard quicksort yourself, it will probably be slower than the one in the STL.

提交回复
热议问题