-
Valid values: Is the iterator dereferenceable? For example, writing "*e.end()" is always a programming error.
-
Valid lifetimes: Is the iterator still valid when it's being used? Or has it been invalidated by some operation since we obtained it?
-
Valid ranges: Is a pair of iterators a valid range? Is first really before (or equal to) last? Do both really point into the same container?
-
Illegal builtin manipulation: For example, is the code trying to modify a temporary of builtin type, as in "--e.end()" above? (Fortunately, the compiler can often catch this kind of mistake for you, and for iterators of class type, the library author will often choose to allow this sort of thing for syntactic convenience.)
关于 Iterators
最新推荐文章于 2024-07-23 14:33:45 发布
本文探讨了使用迭代器时应注意的四个主要问题:有效值、有效生命周期、有效范围及非法内置操作。这些问题对于确保迭代器的正确使用至关重要。
When using iterators, be aware of four main issues.
739

被折叠的 条评论
为什么被折叠?



