C++ STL: Can arrays be used transparently with STL functions?

后端 未结 11 1312
半阙折子戏
半阙折子戏 2020-12-15 17:07

I was under the assumption that STL functions could be used only with STL data containers (like vector) until I saw this piece of code:

#include         


        
11条回答
  •  旧巷少年郎
    2020-12-15 17:50

    Pointers model Trivial Iterator, and pointer from arrays model Random Access Iterator. So yes, it's perfectly legal.

    If you are interested on the usage constraints of each S(T)L algorithm, familiarize yourself the iterator models.

提交回复
热议问题