gpt4 book ai didi

c++ - 标准中术语相同、相等、等效的含义

转载 作者:太空狗 更新时间:2023-10-29 20:33:20 28 4
gpt4 key购买 nike

标准中至少有三个具有相似含义的术语:identicalequalequivalent。所有这些在描述算法时都会用到。说,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

当谈到关联容器时,使用了等效这个词。对于两个元素 ab这意味着(大致)!(a < b) && !(b < a) .而等于表示a == b .

相同 是什么意思?它在标准中有定义吗?

最佳答案

我在标准的相关章节中找不到“相同”的定义。看起来像这个词的口语用法。您的报价来自 cppreference 这一事实进一步支持了这一点。 adjacent_find在标准中的规范定义是specified in terms of == (or a predicate) directly :

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 是一种宝贵的资源,但其目标是将标准文本消化为易于访问和理解的 Material 。有时,它会使用口语化的词语来进行直观的解释。这是一个这样的案例。

关于c++ - 标准中术语相同、相等、等效的含义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55823470/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com