std::shared_ptr<T>::owner_equal
|
|
|
Member functions | ||||
Modifiers | ||||
Observers | ||||
(C++17)
|
||||
(until C++20*)
|
||||
(C++26)
|
||||
shared_ptr::owner_equal (C++26) |
||||
Non-member functions | ||||
(until C++20)
(until C++20)
(until C++20)
(until C++20)
(until C++20)
(C++20)
|
||||
functions (until C++26*)
|
||||
Helper classes | ||||
(C++20)
|
||||
Deduction guides(C++17) |
template
<
class Y >
bool owner_equal( const std::shared_ptr <Y> & other ) const noexcept ; |
(1) | (since C++26) |
template
<
class Y >
bool owner_equal( const std::weak_ptr <Y> & other ) const noexcept ; |
(2) | (since C++26) |
Checks whether this shared_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()
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
Feature-test macro | Value | Std | Feature |
---|---|---|---|
__cpp_lib_smart_ptr_owner_equality |
202306L |
(C++26) | Enabling the use of std::shared_ptr as keys in unordered associative containers
|
Example
This section is incomplete Reason: example |
See also
(C++26)
|
provides mixed-type owner-based equal comparisons of shared and weak pointers (class) |