std::bad_weak_ptr
提供: cppreference.com
<tbody>
</tbody>

| ヘッダ <memory> で定義
|
||
class bad_weak_ptr; |
(C++11以上) | |
std::bad_weak_ptr は、 std::weak_ptr がすでに削除されたオブジェクトを参照しているとき、引数として std::weak_ptr を取る std::shared_ptr のコンストラクタによって、例外として投げられるオブジェクトの型です。
継承図
メンバ関数
| bad_weak_ptr オブジェクトを構築します (パブリックメンバ関数) |
std::bad_weak_ptr ::bad_weak_ptr()
<tbody> </tbody> bad_weak_ptr() noexcept; |
||
std::bad_weak_ptr の新しいインスタンスを構築します。 what() は処理系定義のヌル終端バイト文字列を返します。
引数
(なし)
std::exception から継承
メンバ関数
[仮想] |
例外オブジェクトを破棄します ( std::exceptionの仮想パブリックメンバ関数)
|
[仮想] |
説明文字列を返します ( std::exceptionの仮想パブリックメンバ関数)
|
例
Run this code
#include <memory>
#include <iostream>
int main()
{
std::shared_ptr<int> p1(new int(42));
std::weak_ptr<int> wp(p1);
p1.reset();
try {
std::shared_ptr<int> p2(wp);
} catch(const std::bad_weak_ptr& e) {
std::cout << e.what() << '\n';
}
}
出力:
std::bad_weak_ptr
関連項目
(C++11) |
共有オブジェクト所有権のセマンティクスを持つスマートポインタ (クラステンプレート) |
(C++11) |
std::shared_ptr によって管理されているオブジェクトへの弱参照 (クラステンプレート) |