【发布时间】:2014-04-26 01:33:22
【问题描述】:
根据C++ reference,前向迭代器的要求是它支持后自增运算符(即iterator operator++(int)和
我想知道在自定义转发迭代器上disallow 这个操作是否安全,即
custom_iterator operator++(int) = delete; // disallow post-increment, i.e. it++
custom_iterator operator++() { ... } // we only define pre-increment, i.e. ++it
并假设 STL 永远不会在这样的自定义迭代器 it 上调用 it++,当它作为参数传递给 STL 通用算法(例如 copy、sort、fill 等)时?
官方 C++11 标准中关于这个问题的引用将是最有用的,但也欢迎回答诸如“大多数实现都做这个和那个”之类的答案。
【问题讨论】:
标签: c++ c++11 iterator standards c++-standard-library