问题描述
C++ 标准 (2003) 中的第 24.1/5 节写道,
The section §24.1/5 from the C++ Standard (2003) reads,
就像一个普通的指向数组的指针一样保证有一个指针指向最后一个元素的值的数组,所以对于任何迭代器类型有一个迭代器值指向经过 a 的最后一个元素对应的容器.这些值被称为过终值.价值观迭代器 i 的表达式 *i 被定义被调用可解引用.图书馆从不假设最后的值是可解引用.迭代器也可以具有不属于的奇异值与任何容器相关联.[示例:在声明一个未初始化的指针 x(与 int*x;),必须始终假设 x 具有指针的奇异值.]大多数表达式的结果是对于奇异值未定义;这唯一的例外是赋值迭代器的非奇异值持有一个奇异值.在这种情况下奇异值被覆盖与任何其他值相同的方式.可取消引用的值总是非奇异.
Just as a regular pointer to an array guarantees that there is a pointer value pointing past the last element of the array, so for any iterator type there is an iterator value that points past the last element of a corresponding container. These values are called past-the-end values. Values of an iterator i for which the expression *i is defined are called dereferenceable. The library never assumes that past-the-end values are dereferenceable. Iterators can also have singular values that are not associated with any container. [Example: After the declaration of an uninitialized pointer x (as with int* x;), x must always be assumed to have a singular value of a pointer.] Results of most expressions are undefined for singular values; the only exception is an assignment of a non-singular value to an iterator that holds a singular value. In this case the singular value is overwritten the same way as any other value. Dereferenceable values are always nonsingular.
我真的无法理解以粗体显示的文字?
I couldn't really understand the text shown in bold?
- 什么是奇异值和非奇异值?它们是如何定义的?在哪里?
- 如何以及为什么可解引用值总是非奇异的?
- What is singular value and nonsingular value? How are they defined? And where?
- How and why dereferenceable values are always nonsingular?
推荐答案
迭代器也可以具有不与任何容器相关联的奇异值.
我想这就是它的定义.
可解引用的值如何以及为什么总是非奇异的?
How and why dereferenceable values are always nonsingular?
因为如果他们不这样做,取消引用他们将是未定义的行为.
Because if they wouldn't, dereferencing them would be undefined behavior.
这篇关于STL 迭代器上下文中的奇异值和非奇异值是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!