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) | (C++26以降) |
|
template
<
class
Y
>
bool owner_equal ( const std:: weak_ptr < Y > & other ) const noexcept ; |
(2) | (C++26以降) |
この
shared_ptr
と
other
が所有権を共有しているか、または両方とも空であるかをチェックします。この比較は、2つのスマートポインタが両方とも空である場合、または同じオブジェクトを所有している場合にのみ等価と評価されます。これは、
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::shared_ptr
を
非順序連想コンテナ
のキーとして使用可能にする
|
例
|
このセクションは不完全です
理由: example |
関連項目
|
(C++26)
|
共有ポインタと弱ポインタの混合型所有者ベース等値比較を提供する
(クラス) |