std::owner_equal
Header: <memory>
This function object provides owner-based (as opposed to value-based) mixed-type equal comparison of both std::weak_ptr and std::shared_ptr. The comparison is such that two smart pointers compare equivalent only if they are both empty or if they share ownership, even if the values of the raw pointers obtained by get() are different (e.g. because they point at different subobjects within the same object).
# Declarations
struct owner_equal;
(since C++26)
# Parameters
lhs, rhs: shared-ownership pointers to compare
# Return value
true if lhs and rhs are both empty or share ownership as determined by the owner-based equal comparison, false otherwise.
# Notes
Feature-test macro Value Std Feature __cpp_lib_smart_ptr_owner_equality 202306L (C++26) Enabling the use of std::shared_ptr and std::weak_ptr as keys in unordered associative containers