Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/161.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
c+中是否没有超时异常+;? 我正在寻找标准C++中的STD::TimeOutExb异常(StestCePT)。我还没找到_C++_Exception_Std - Fatal编程技术网

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++标准没有定义任何超时的东西(我所知道的都不)。因此,没有任何东西可能引发这样的异常。