Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::owner_hash

      From cppreference.com
      <cpp‎ |memory
       
       
      Memory management library
      (exposition only*)
      Allocators
      Uninitialized memory algorithms
      Constrained uninitialized memory algorithms
      Memory resources
      Uninitialized storage(until C++20)
      (until C++20*)
      (until C++20*)
      Garbage collector support(until C++23)
      (C++11)(until C++23)
      (C++11)(until C++23)
      (C++11)(until C++23)
      (C++11)(until C++23)
      (C++11)(until C++23)
      (C++11)(until C++23)
       
      Defined in header<memory>
      struct owner_hash;
      (since C++26)

      This function object provides owner-based (as opposed to value-based) hashing of bothstd::weak_ptr andstd::shared_ptr.

      Contents

      [edit]Nested types

      Nested type Definition
      is_transparentunspecified

      [edit]Member functions

      operator()
      calculates the hash of the shared-ownership pointer
      (function)

      std::owner_hash::operator()

      template<class T>
      std::size_t operator()(conststd::shared_ptr<T>& key)constnoexcept;
      (1)(since C++26)
      template<class T>
      std::size_t operator()(conststd::weak_ptr<T>& key)constnoexcept;
      (2)(since C++26)

      Equivalent toreturn key.owner_hash();.

      Parameters

      key - shared-ownership pointer to be hashed

      Return value

      A hash value that is identical for anystd::shared_ptr orstd::weak_ptr object sharing the same ownership.

      [edit]Notes

      Feature-test macroValueStdFeature
      __cpp_lib_smart_ptr_owner_equality202306L(C++26)Enabling the use ofstd::shared_ptr andstd::weak_ptr as keys inunordered associative containers

      [edit]See also

      (C++26)
      provides owner-based hashing of shared pointers
      (public member function ofstd::shared_ptr<T>)[edit]
      (C++26)
      provides owner-based hashing of weak pointers
      (public member function ofstd::weak_ptr<T>)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/memory/owner_hash&oldid=171429"

      [8]ページ先頭

      ©2009-2025 Movatter.jp