- memory[meta header]
- std[meta namespace]
- out_ptr_t[meta class]
- function[meta id-type]
- cpp23[meta cpp]
~out_ptr_t();指定したSmart型スマートポインタに、レガシーC関数呼び出しにより取得されたポインタ値を格納する。
スマートポインタへのポインタ値格納には、Smart::reset()メンバ関数、もしくはSmartオブジェクト構築+ムーブ代入operator=が利用される。
- オブジェクト単位でカスタムデリータを管理する
std::shared_ptr<T>の場合、out_ptr_tコンストラクタにてデリータオブジェクトを渡しておくことで、reset()呼び出しの取得ポインタ値に続く引数として渡される。 この動作はout_ptr_tクラステンプレートの適格要件にて強制される。 - 型レベルでカスタムデリータを管理する
std::unique_ptr<T,D>の場合、reset()呼び出しには取得ポインタ値のみが渡される。 - これ以外のスマートポインタ型では、同スマートポインタの動作セマンティクスに従う。
説明用のSP型を下記の通り定義する :
Smart::pointerが有効な型名であればSmart::pointer- そうでなければ、
Smart::element_type*が有効な型名であればSmart::element_type* - そうでなければ、
pointer_traits<Smart>::element_type* - そうでなければ、
Pointer
説明用メンバ変数s, a, pを用いて、以下と同じ効果を持つ :
-
式
s.reset(static_cast<SP>(p),std::forward<Args>(args)...)が適格ならば、if (p) { apply([&](auto&&... args) { s.reset(static_cast<SP>(p), std::forward<Args>(args)...); }, std::move(a)); }
- apply[link /reference/tuple/apply.md]
-
is_constructible_v<Smart, SP, Args...>がtrueならば、if (p) { apply([&](auto&&... args) { s = Smart(static_cast<SP>(p), std::forward<Args>(args)...); }, std::move(a)); }
- apply[link /reference/tuple/apply.md]
-
そうでなければ、プログラムは不適格となる。
- C++23
- Clang: ??
- GCC: ??
- ICC: ??
- Visual C++: ??