std::weak_ptr<T>:: owner_equal
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
| Modifiers | ||||
| Observers | ||||
|
(C++26)
|
||||
|
weak_ptr::owner_equal
(C++26)
|
||||
| Non-member functions | ||||
| Helper classes | ||||
|
(C++20)
|
||||
| Deduction guides (C++17) |
|
template
<
class
Y
>
bool owner_equal ( const std:: weak_ptr < Y > & other ) const noexcept ; |
(1) | (C++26以降) |
|
template
<
class
Y
>
bool owner_equal ( const std:: shared_ptr < Y > & other ) const noexcept ; |
(2) | (C++26以降) |
この
weak_ptr
と
other
が所有権を共有しているか、または両方が空であるかをチェックします。この比較は、両方のスマートポインタが空である場合、または両方が同じオブジェクトを所有している場合にのみ等価と判定されます。たとえ
get()
によって取得されたポインタの値が異なっていても(例えば、同じオブジェクト内の異なるサブオブジェクトを指している場合)、この条件は変わりません。
メンバ関数
owner_equal
は同値関係であり、
!
owner_before
(
other
)
&&
!
other.
owner_before
(
*
this
)
が
true
である場合に限り、
owner_equal
(
other
)
が
true
となります。
この順序付けは、共有ポインタおよび弱ポインタを非順序連想コンテナのキーとして使用できるようにするために用いられます。通常は std::owner_equal を通じて実現されます。
目次 |
パラメータ
| other | - | 比較対象の std::shared_ptr または std::weak_ptr |
戻り値
true が返されるのは、 * this と other が所有権を共有している場合、または両方が空の場合です。それ以外の場合は false が返されます。
注記
| 機能テスト マクロ | 値 | 標準 | 機能 |
|---|---|---|---|
__cpp_lib_smart_ptr_owner_equality
|
202306L
|
(C++26) |
std::weak_ptr
を
非順序連想コンテナ
のキーとして使用可能にする
|
例
|
このセクションは不完全です
理由: example |
関連項目
|
(C++26)
|
共有ポインタと弱ポインタの混合型所有者ベース等値比較を提供する
(クラス) |