std::hash(std::shared_ptr)

template<class T> struct hash<shared_ptr<T>>;
(C++11 起)

std::hashstd::shared_ptr<T> 的模板特化允许用户获得 std::shared_ptr<T> 类型对象的哈希。

对于给定的 std::shared_ptr<T> p ,此特化确保

std::hash<std::shared_ptr<T>>()(p) == std::hash<T*>()(p.get()).

(C++17 前)

std::hash<std::shared_ptr<T>>()(p) == std::hash<typename std::shared_ptr<T>::element_type*>()(p.get()).

(C++17 起)

示例

参阅

(C++11)
哈希函数对象
(类模板)

版本历史

  • (当前 | 先前 2017年9月3日 (日) 09:43Fruderica讨论 | 贡献. . (797字节) (-350). . (撤销)
  • 当前 | 先前 2014年10月26日 (日) 17:56P12bot讨论 | 贡献 . . (1,147字节) (0). . (Fix some translations) (撤销)
  • 当前 | 先前 2013年7月2日 (二) 09:06P12bot讨论 | 贡献 . . (1,147字节) (-61). . (Use {{lc}}. Update links. Various fixes.) (撤销)
  • 当前 | 先前 2012年11月2日 (五) 15:00P12bot讨论 | 贡献 . . (1,208字节) (+273). . (r2.7.3) (机器人添加:de, en, es, fr, it, ja, pt, ru) (撤销)
  • 当前 | 先前 2012年10月27日 (六) 03:40P12讨论 | 贡献 . . (935字节) (0). . (1个修订: Translate from the English version) (撤销)
  • 当前 | 先前 2012年10月26日 (五) 06:00TranslationBot讨论 | 贡献. . (935字节) (-19). . (Translated from the English version using Google Translate) (撤销)
  • 当前 | 先前 2012年10月25日 (四) 14:55P12讨论 | 贡献 . . (954字节) (0). . (1个修订: Translate from the English version) (撤销)
  • 当前 | 先前) 2012年10月25日 (四) 12:00TranslationBot讨论 | 贡献. . (954字节) (+954). . (Translated from the English version using Google Translate)