bad_weak_ptr 클래스
불량 weak_ptr 예외를 보고합니다.
구문
class bad_weak_ptr : public std::exception
{
bad_weak_ptr();
const char *what() throw();
};
설명
이 클래스는 weak_ptr 클래스 형식의 인수를 사용하는 shared_ptr 클래스 생성자에서 throw될 수 있는 예외를 설명합니다. 멤버 함수 what
에서 "bad_weak_ptr"
을 반환합니다.
예시
// std__memory__bad_weak_ptr.cpp
// compile with: /EHsc
#include <memory>
#include <iostream>
int main()
{
std::weak_ptr<int> wp;
{
std::shared_ptr<int> sp(new int);
wp = sp;
}
try
{
std::shared_ptr<int> sp1(wp); // weak_ptr has expired
}
catch (const std::bad_weak_ptr&)
{
std::cout << "bad weak pointer" << std::endl;
}
catch (...)
{
std::cout << "unknown exception" << std::endl;
}
return (0);
}
bad weak pointer
참고 항목
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기