std:: owner_less
|
ヘッダーで定義
<memory>
|
||
| (1) | ||
|
template
<
class
T
>
struct owner_less ; /* undefined */ |
(C++11以降)
(C++17まで) |
|
|
template
<
class
T
=
void
>
struct owner_less ; /* undefined */ |
(C++17以降) | |
|
template
<
class
T
>
struct owner_less < std:: shared_ptr < T >> ; |
(2) | (C++11以降) |
|
template
<
class
T
>
struct owner_less < std:: weak_ptr < T >> ; |
(3) | (C++11以降) |
|
template
<>
struct owner_less < void > ; |
(4) | (C++17以降) |
この関数オブジェクトは、所有者ベース(値ベースではなく)の混合型順序付けを
std::weak_ptr
と
std::shared_ptr
の両方に対して提供します。この順序は、2つのスマートポインタがともに空であるか、所有権を共有している場合にのみ等価と比較されるように定義されており、
get()
によって取得された生ポインタの値が異なっていても(例えば同じオブジェクト内の異なるサブオブジェクトを指している場合など)、比較結果に影響しません。
デフォルトの operator < はweak pointerに対して定義されておらず、同一オブジェクトを指す二つのshared pointerを不適切に非等価と判定する可能性があります( std::shared_ptr::owner_before を参照)。
特殊化
標準ライブラリは
|
(C++17以降) |
ネストされた型
|
(C++20まで) |
メンバー関数
|
operator()
|
引数を所有者ベースのセマンティクスを使用して比較する
(関数) |
std::owner_less:: operator()
|
特殊化のみのメンバー
(2)
|
||
|
bool
operator
(
)
(
const
std::
shared_ptr
<
T
>
&
lhs,
const std:: shared_ptr < T > & rhs ) const noexcept ; |
(C++11以降) | |
|
特殊化のみのメンバー
(3)
|
||
|
bool
operator
(
)
(
const
std::
weak_ptr
<
T
>
&
lhs,
const std:: weak_ptr < T > & rhs ) const noexcept ; |
(C++11以降) | |
|
両方のテンプレート特殊化のメンバー
|
||
|
bool
operator
(
)
(
const
std::
shared_ptr
<
T
>
&
lhs,
const std:: weak_ptr < T > & rhs ) const noexcept ; |
(C++11以降) | |
|
bool
operator
(
)
(
const
std::
weak_ptr
<
T
>
&
lhs,
const std:: shared_ptr < T > & rhs ) const noexcept ; |
(C++11以降) | |
lhs と rhs をオーナーベースのセマンティクスで比較します。実質的に lhs. owner_before ( rhs ) を呼び出します。
順序付けは狭義の弱順序関係です。
lhs と rhs は、両方が空であるか、所有権を共有している場合にのみ等価です。
パラメータ
| lhs, rhs | - | 比較する共有所有権ポインタ |
戻り値
true は、オーナーベースの順序付けによって lhs が より小さい rhs である場合、 false はそれ以外の場合。
欠陥報告
以下の動作変更の欠陥報告書は、以前に公開されたC++規格に対して遡及的に適用されました。
| DR | 適用対象 | 公開時の動作 | 正しい動作 |
|---|---|---|---|
| LWG 2873 | C++11 | operator ( ) noexceptであることが要求されていなかった | noexceptであることが要求される |
関連項目
|
共有ポインタの所有者ベースの順序付けを提供
(
std::shared_ptr<T>
の公開メンバ関数)
|
|
|
弱ポインタの所有者ベースの順序付けを提供
(
std::weak_ptr<T>
の公開メンバ関数)
|