std::weak_ptr::owner_equal(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’… std::weak_ptr::owner_equal πŸ’…

okay so this is the C++ Standard Libary manual page for std::weak_ptr::owner_equal β€” yes bestie, the title and the NAME line are literally twins, she's consistent and we love that for her πŸ’–

🌸 NAME 🌸

std::weak_ptr::owner_equal - std::weak_ptr::owner_equal

✨ Synopsis ✨

here's the synopsis, and both overloads are since C++26 β€” also yes, noexcept is right there in the signature, no cap:

template< class Y >
bool owner_equal( const std::weak_ptr<Y>& other ) const noexcept;

template< class Y >
bool owner_equal( const std::shared_ptr<Y>& other ) const noexcept;
  • overload (1) β€” the std::weak_ptr<Y> one, (since C++26)
  • overload (2) β€” the std::shared_ptr<Y> one, (since C++26)

Checks whether this weak_ptr and other share ownership or are both empty. The comparison is such that two smart pointers compare equivalent only if they are both empty or if they both own the same object, even if the values of the pointers obtained by get() are different (e.g. because they point at different subobjects within the same object).

The member function owner_equal is an equivalence relation such that !owner_before(other) && !other.owner_before(*this) is true if and only if owner_equal(other) is true.

This ordering is used to make shared and weak pointers usable as keys in unordered associative containers, typically through std::owner_equal.

πŸ’– Parameters πŸ’–

  • other β€” the std::shared_ptr or std::weak_ptr to be compared

πŸŽ€ Return value πŸŽ€

true if *this and other share ownership or are both empty. Otherwise, returns false.

πŸ¦‹ Notes πŸ¦‹

the feature-test macro tea β˜• is giving:

  • feature-test macro: __cpp_lib_smart_ptr_owner_equality
    • value: 202306L
    • std: (C++26)
    • feature: enabling the use of std::weak_ptr as keys in unordered associative containers

🌈 Example 🌈

This section is incomplete.

Reason: example

πŸ”₯ See also πŸ”₯

  • owner_equal β€” provides mixed-type owner-based equal comparisons of shared and weak (C++26) pointers (class)

πŸ‘‘ Category πŸ‘‘

  • * Todo with reason

okay bye bestie 🫢 this page is from http://cppreference.com, dated 2024.06.10 β€” it's the std::weak_ptr::owner_equal(3) page, and it ate, periodt πŸ’…βœ¨

πŸ“¦ where this page comes from