std::owner_hash(3)

πŸ“¦
version 2024.07.05 Β· 2 versions
, in nixpkgs unstable, opensuse-leap 16.0

πŸ¦‹ std::owner_hash(3) πŸ¦‹

okay so bestie, welcome to std::owner_hash(3) β€” this is straight outta the C++ Standard Libary manual. we're talking owner-based hashing today, and yes it's giving main character energy. πŸ’…

🌸 NAME 🌸

std::owner_hash - std::owner_hash

✨ Synopsis ✨

bestie, here's where it lives:

Defined in header <memory>

struct owner_hash;          (since C++26)

This function object provides owner-based (as opposed to value-based) hashing of both std::weak_ptr and std::shared_ptr. no cap, that's the whole vibe. 🫢

πŸ’… Member functions πŸ’…

  • operator() β€” calculates the hash of the shared-ownership pointer (function)

🌈 std::owner_hash::operator() 🌈

the signatures are literally right here:

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

Equivalent to return key.owner_hash();.

πŸŽ€ Parameters πŸŽ€

  • key β€” shared-ownership pointer to be hashed

πŸ“ Return value πŸ“

A hash value that is identical for any std::shared_ptr or std::weak_ptr object sharing the same ownership. slay, consistency. ✨

πŸ”₯ Notes πŸ”₯

here's the feature-test macro tea, bestie:

  • Feature-test macro: __cpp_lib_smart_ptr_owner_equality
  • Value: 202306L
  • Std: (C++26)
  • Feature: Enabling the use of std::shared_ptr and std::weak_ptr as keys in unordered associative containers

🌈 See also 🌈

  • owner_hash provides owner-based hashing of shared pointers (C++26) β€” (public member function of std::shared_ptr<T>)
  • owner_hash provides owner-based hashing of weak pointers (C++26) β€” (public member function of std::weak_ptr<T>)

okay that's the whole page, bestie 🫢 source: http://cppreference.com Β· date: 2024.06.10 Β· page: std::owner_hash(3). go be iconic with your hashing, periodt πŸ’–βœ¨

πŸ“¦ where this page comes from