c++11 foreach syntax and custom iterator

前端 未结 4 1388
野性不改
野性不改 2020-12-23 16:07

I am writing an iterator for a container which is being used in place of a STL container. Currently the STL container is being used in many places with the c++11 foreach syn

4条回答
  •  长情又很酷
    2020-12-23 16:32

    You have two choices:

    • you provide member functions named begin and end that can be called like C.begin() and C.end();
    • otherwise, you provide free functions named begin and end that can be found using argument-dependent lookup, or in namespace std, and can be called like begin(C) and end(C).

提交回复
热议问题