c+中是否没有超时异常+;? 我正在寻找标准C++中的STD::TimeOutExb异常(StestCePT)。我还没找到
好的-我可以建立自己的:c+中是否没有超时异常+;? 我正在寻找标准C++中的STD::TimeOutExb异常(StestCePT)。我还没找到,c++,exception,std,C++,Exception,Std,好的-我可以建立自己的: class timeout_exception : public std::runtime_error { public: using std::runtime_error::runtime_error; }; 标准库中真的没有超时异常吗?我必须自己定义吗?不,没有std::timeout\u异常。标准不需要定义它,因为标准库中没有任何东西可以抛出它 最明显的候选者是std::timed_lock,但是try_lock\u for和try_lock\u,直到返回f
class timeout_exception : public std::runtime_error {
public:
using std::runtime_error::runtime_error;
};
标准库中真的没有超时异常吗?我必须自己定义吗?不,没有
std::timeout\u异常。标准不需要定义它,因为标准库中没有任何东西可以抛出它
最明显的候选者是std::timed_lock
,但是try_lock\u for
和try_lock\u,直到
返回false
你的定义看起来不错。
你需要定义你自己的类:你认为什么是可行的TimeOutExub异常?名字?您的定义与运行时错误
没有其他区别。标准库应该在哪里使用它?如果没有,为什么标准库应该定义一个它从未使用过的异常?@Jodocus:他可以显式地捕获timeout\u,但
除外,并让其他运行时错误通过。@MartinBonner我知道,但为什么它应该是标准库的一部分?为什么这么令人惊讶?C++标准没有定义任何超时的东西(我所知道的都不)。因此,没有任何东西可能引发这样的异常。