Should I prefer iterators over const_iterators?

前端 未结 6 2173
没有蜡笔的小新
没有蜡笔的小新 2020-12-14 16:07

Someone here recently brought up the article from Scott Meyers that says:

  • Prefer iterators over const_iterators (pdf link).
6条回答
  •  醉话见心
    2020-12-14 16:48

    By my reading of that link, Meyers appears to be fundamentally saying that interator's are better than const_interator's because you cannot make changes via a const_iterator.

    But if that is what he is saying then Meyers is in fact wrong. This is precisely why const_iterator's are better than iterator's when that is what you want to express.

提交回复
热议问题