C++ iterators considered harmful?

后端 未结 13 560
忘了有多久
忘了有多久 2020-12-23 03:42

At the Boost library conference today, Andrei Alexandrescu, author of the book Modern C++ Design and the Loki C++ library, gave a talk titled \"Iterators Must Go\" (video, s

相关标签:
13条回答
  • 2020-12-23 04:08

    Andrei at times can be a bit provocative. Iterators are a reasonable concept, and quite fundamental in the sense that bits are. But just like most bits in C++ are not bools, but part of larger types,most iterators should be dealt with at a high level. Andrei is right that the proper level to do so is the range object. But not all ranges are properly exposed as iterator ranges, as the istream_iterator sentinel shows. That's just a hack to create an artificial end iterator. I don't think his ideas will be picked up by implementations, though. C++1x will be as relevant as C99.

    0 讨论(0)
提交回复
热议问题