gpt4 book ai didi

c++ - 不同电脑的typeid一样吗?

转载 作者:行者123 更新时间:2023-12-01 13:19:32 26 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





Why is std::hash not guaranteed to be deterministic?

(2 个回答)


去年关闭。




我想知道是否hash_code() typeid 在不同的电脑上是一样的吗?例如:如果 typeid(int).hash_code()在另一台电脑上会一样吗?

最佳答案

I am wondering if hash_code() of typeid is the same on different computers?


它可能是也可能不是。来自 cppreference行为是:

Returns an unspecified value such that for all type_info objects referring to the same type, their hash_code() is the same.

No other guarantees are given: type_info objects referring to different types may have the same hash_code (although the standard recommends that implementations avoid this as much as possible), and hash_code for the same type can change between invocations of the same program.

关于c++ - 不同电脑的typeid一样吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61080873/

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