- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
如果我使用 libstdc++
做了 std::hash
然后在即将到来的 C++11
VS 2012 库上做了一个 - 他们会匹配吗?
我假设哈希实现不是 C++ 规范的一部分,并且会因分布而异?
最佳答案
标准只说明了这一点:
20.8.12 Class template hash The unordered associative containers defined in 23.5 use specializations of the class template hash as the default hash function. For all object types Key for which there exists a specialization hash, theinstantiation hash shall:
- satisfy the Hash requirements (17.6.3.4), with Key as the function call argument type, the DefaultConstructible requirements (Table 19), the CopyAssignable requirements (Table 23),
- be swappable (17.6.3.2) for lvalues,
- provide two nested types result_type and argument_type which shall be synonyms for size_t and Key, respectively,
- satisfy the requirement that if k1 == k2 is true, h(k1) == h(k2) is also true, where h is an object of type hash and k1 and k2 are objects of type Key.
在 17.6.3.4 中,这是最重要的(表 26):
Shall not throw exceptions. The value returned shall depend only on the argument k. [ Note: Thus all evaluations of the expression h(k) with the same value for k yield the same result. — end note ] [ Note: For two different values t1 and t2, the probability that h(t1) and h(t2) compare equal should be very small, approaching 1.0 / numeric_- limits::max(). — end note ]
所以一般来说,不,计算本身没有定义,结果不需要在实现上保持一致。就此而言,即使是同一个库的两个不同版本也可能给出不同的结果。
关于c++ - std::hash 是否保证在 stdlib 发行版中相同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11990794/
我在 Agda 中处理字符串,并且我有它们的向量。我需要检查给定字符串是否出现在向量中(作为检查变量是否自由或绑定(bind)在表达式中的一部分,在我正在做的 PL 理论 wprk 中)。 我仍在寻找
我正在编译大量使用 srand() 和 rand() 的文件,但不包括 stdlib.h。我知道这是不好的做法,但是由于我无法更改正在编译的文件,因此无法在每个文件中插入必要的 include 语句。
我想在我的 Rails 应用程序中使用 Date::ABBR_MONTHS 常量。我在 http://www.ruby-doc.org/stdlib/ 看到了 Ruby stdlib 文档似乎没有这个
昨天我更新了 Android Studio 版本和 Kotlin 插件版本。 Android Studio 版本:3.1.2 Kotlin 版本:1.2.41 当我使用此配置创建 Android 项目
我是使用 CGAL 库的初学者,在组合 CGAL 后,我尝试在 fedora 上运行一个组合映射示例 qt-creator: #include #include #include #includ
Android Studio 2.3.3; Kotlin 插件:1.1.4; Kotlin 编译器:Kotlin 到 JVM:1.6。 Android Studio > 新建项目 > 在项目操作中配置
我有使用 opengl 和 CGAL 的 c++ qt 项目,但我有以下错误: /usr/include/c++/7/cstdlib:75:15: fatal error: stdlib.h: No
我知道的一件事可能不是真的,那就是 T应该是可复制构造的,即T应该有一个可访问的复制构造函数。 但是,是否还有其他要求,例如copy assignable? 作为补充,我记得 Effective ST
此代码片段主要来自 qsort 的手册页。 int cmp(const void *p1, const void *p2) { char s1 = *(*(char * const *)p1);
在现代 C++ 中,标准库是否提供类型列表模板? int main() { using int_types = type_list; std::cout ::value ::type)
我一直在想,C++ 中的设计决策是否有任何理由不为任何标准库容器提供纯抽象类? 我很欣赏 hash_map 后来来自 stdext 命名空间,但共享一个非常相似的接口(interface)。如果我后来
这个问题在这里已经有了答案: What is the use of _start() in C? (4 个答案) 关闭 6 年前。 采用以下 C 程序: int main(){} 它没有使用 C 标
关注此blog post我试图编译 stdlib.so 以将其他代码与其链接。不幸的是,stdlib.so 本身是一个动态链接的二进制文件: # ldd /usr/local/go/pkg/linux
作为一个 puppet 新手,我有一个问题,包括 stdlib 插件 我想使用 stdlib 的 file_line,因此我尝试包含 stdlib 并调用它 class service_mon {
我正在尝试在我创建的类中使用 stdlib 堆栈,但我在动态创建它时遇到问题。 这是我的头文件“matcher.h”中的相关代码: private: stack opens;
我已经更新了我的一个非常旧的项目(XCODE 4.5.1 baseSDK iOS6)并且由于某种原因我得到了上面的错误。 它只为 iOS5+ 编译但不适用于 iOS 4.3 ? 有什么想法吗? 最佳答
我有一个使用标准库 fopen/fclose 函数实现的文件 IO 接口(interface),它运行良好,直到我们不得不将其更改为同步实现以防止数据丢失(一种情况)。所以我用系统调用(open()/
这个问题在这里已经有了答案: 关闭 11 年前。 Possible Duplicate: How does system() exactly work in linux? 出于好奇,我想知道 sys
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 7 年前。 Improve
已关闭。这个问题是 not reproducible or was caused by typos 。目前不接受答案。 这个问题是由拼写错误或无法再重现的问题引起的。虽然类似的问题可能是 on-top
我是一名优秀的程序员,十分优秀!