在STL迭代器的上下文中,单数和非奇异值是什么? [英] What is singular and non-singular values in the context of STL iterators?
问题描述
C ++标准(2003)中的§24.1/ 5一节中的
只是作为数组的常规指针
保证有一个指针
值指向超过数组的最后一个元素
,所以对于任何迭代器类型
,有一个迭代器值指向
超过最后一个元素的一个
对应的容器。这些值
称为过期值。定义了
表达式* i的迭代器i的值
称为
dereferenceable。库从不
假定过去的结束值是
dereferenceable。 迭代器也可以
有奇异值,而不是
与任何容器相关联。
[示例:声明
后未初始化的指针x与int *
x;),x必须总是假定有
a指针的奇异值。]
大多数表达式的结果是
未定义奇异值;
唯一的例外是一个
非奇异值赋值给一个迭代器,
拥有一个奇异值。在这种情况下
奇异值被覆盖的
与任何其他值相同的方式。
可引用的值总是
nonsingular。
我真的不明白粗体?
- 什么是奇异值和非奇异值?如何定义它们?
迭代器也可以有不与任何容器相关联的奇异值。。
p>
我想这是它的定义。
因为如果它们不会,那么解除引用它们将是未定义的行为。
The section §24.1/5 from the C++ Standard (2003) reads,
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?
Iterators can also have singular values that are not associated with any container.
I suppose that's its definition.
How and why dereferenceable values are always nonsingular?
Because if they wouldn't, dereferencing them would be undefined behavior.
这篇关于在STL迭代器的上下文中,单数和非奇异值是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!