标准中术语相同、相等、等效的含义
Meaning of terms identical, equal, equivalent in the Standard
标准中至少有三个具有相似含义的术语:相同、相等和等效。所有这些在描述算法时都会用到。比如说,std::adjacent_find
:
Searches the range [first, last)
for two consecutive identical elements.
但是比较器的描述说:
binary predicate which returns true if the elements should be treated as equal
当谈到关联容器时,使用了等效这个词。对于两个元素 a
和 b
,它意味着(大致)!(a < b) && !(b < a)
。而 等于 表示 a == b
.
术语相同是什么意思?它在标准中有定义吗?
我在标准的相关部分找不到 "identical" 的定义。看起来像这个词的口语用法。您的报价来自 cppreference 这一事实进一步支持了这一点。标准中adjacent_find
的规范定义是根据==
规定的
(或谓词)直接:
Returns: The first iterator i
such that both i
and i + 1
are in the range [first, last) for which the following corresponding conditions
hold: *i == *(i + 1)
, pred(*i, *(i + 1)) != false
. Returns last if no
such iterator is found.
虽然 cppreference 是一种宝贵的资源,但其目标是将标准文本消化为易于访问和理解的材料。有时,它会使用口语化的词语来进行直观的解释。这就是一个例子。
标准中至少有三个具有相似含义的术语:相同、相等和等效。所有这些在描述算法时都会用到。比如说,std::adjacent_find
:
Searches the range
[first, last)
for two consecutive identical elements.
但是比较器的描述说:
binary predicate which returns true if the elements should be treated as equal
当谈到关联容器时,使用了等效这个词。对于两个元素 a
和 b
,它意味着(大致)!(a < b) && !(b < a)
。而 等于 表示 a == b
.
术语相同是什么意思?它在标准中有定义吗?
我在标准的相关部分找不到 "identical" 的定义。看起来像这个词的口语用法。您的报价来自 cppreference 这一事实进一步支持了这一点。标准中adjacent_find
的规范定义是根据==
规定的
(或谓词)直接:
Returns: The first iterator
i
such that bothi
andi + 1
are in the range [first, last) for which the following corresponding conditions hold:*i == *(i + 1)
,pred(*i, *(i + 1)) != false
. Returns last if no such iterator is found.
虽然 cppreference 是一种宝贵的资源,但其目标是将标准文本消化为易于访问和理解的材料。有时,它会使用口语化的词语来进行直观的解释。这就是一个例子。