std::owner_hash
來自 cppreference.com
定義於標頭檔案 <memory> |
||
struct owner_hash; |
(C++26 起) | |
此函式物件提供基於所有權(而非基於值)的 std::weak_ptr 和 std::shared_ptr 的雜湊。
目錄 |
[edit] 巢狀型別
巢狀型別 | 定義 |
is_transparent
|
未指定 |
[edit] 成員函式
operator() |
計算共享所有權指標的雜湊值 (函式) |
std::owner_hash::operator()
template< class T > std::size_t operator()( const std::shared_ptr<T>& key ) const noexcept; |
(1) | (C++26 起) |
template< class T > std::size_t operator()( const std::weak_ptr<T>& key ) const noexcept; |
(2) | (C++26 起) |
等價於 return key.owner_hash();。
引數
key | - | 要進行雜湊處理的共享所有權指標 |
返回值
對於任何共享相同所有權的 std::shared_ptr 或 std::weak_ptr 物件,其雜湊值是相同的。
[edit] 注意
特性測試宏 | 值 | 標準 | 特性 |
---|---|---|---|
__cpp_lib_smart_ptr_owner_equality |
202306L |
(C++26) | 在無序關聯容器中啟用使用 std::shared_ptr 和 std::weak_ptr 作為鍵 |
[edit] 參閱
(C++26) |
提供共享指標的基於所有權的雜湊 ( std::shared_ptr<T> 的公共成員函式) |
(C++26) |
提供弱指標的基於所有權的雜湊 ( std::weak_ptr<T> 的公共成員函式) |