fco*_*472 5 c++ runtime-error exception
我有一个继承自的异常类的实现std::runtime_error
:
class custom_error : public std::runtime_error {
public:
explicit custom_error(const std::string &arg)
: std::runtime_error(arg){};
~custom_error() noexcept override = default;
};
Run Code Online (Sandbox Code Playgroud)
该实现尽可能与libstdc++
其他子类的实现相同std::runtime_error
.
当对此代码运行铿锵(在某些情况下 - 见下文)时,会发出以下警告:
warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
Run Code Online (Sandbox Code Playgroud)
有关此检查的相关信息,请参见此处.我相信我理解该页面上的信息.特别是,我认为相关信息是a std::runtime_error
及其子类应具有的特征is_nothrow_copy_constructible
.
我无法协调以下内容.
编译器资源管理器上的以下代码演示了is_nothrow_copy_constructible
使用gcc 5.x和更新版本编译时的类,但在使用gcc 4.x编译时则不行.
在我的笔记本电脑上,运行Ubuntu 18.04,同样的类也在is_nothrow_copy_constructible
编译时使用gcc 5,gcc 7,clang 3.8,clang 5和clang 6,所有这些都是在链接时libstdc++.so.6.0.25
.
在运行Ubuntu 14.04实例的travis-ci上,我找不到同一个类的单个配置is_nothrow_copy_constructible
.这包括使用gcc 5,gcc 6,gcc 7,clang 4和clang 5,链接libstdc++.so.6.0.25
.
这是一个特定的travis构建日志,演示了使用gcc 5链接的测试失败libstdc++.so.6.0.25
.(custom_error
简单地重命名Exception
.)
有人可以向我解释一下该课程是否可以确定is_nothrow_copy_constructible
?
对我来说,以上表明答案可能会有所不同:
是相同的.