c++里没有timeout_exception吗?

Is there no timeout_exception in c++?

我正在标准 C++ 库 (stdexcept) 中寻找 std::timeout_exception。我还没找到。

好的 - 我可以自己建造:

class timeout_exception : public std::runtime_error {
public:
  using std::runtime_error::runtime_error;
};

标准库中真的没有超时异常吗?我必须自己定义吗?

没有,没有std::timeout_exception。标准不需要定义它,因为标准库中没有任何东西可以抛出它。

明显的候选者是 std::timed_lock,但 try_lock_fortry_lock_until 只是 return 错误。

你的定义看起来不错。