noexcept取决于成员函数的noexcept [英] noexcept depend on noexcept of a member function
本文介绍了noexcept取决于成员函数的noexcept的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请考虑:
class test {
private:
int n;
int impl()const noexcept {
return n;
}
public:
test()= delete;
test(int n)noexcept:n(n){}
int get()const noexcept(noexcept(impl())){
return impl
}
};
GCC说不:
test.cpp:27:43:error:无法调用成员函数'int test :: impl()const'with
out object
int get()const noexcept (impl())){
同样:
test.cpp:27:38:error:无效的使用'this'在顶层
int get()const noexcept(noexcept(this-& ))){
和
test.cpp:31:58:error:无效使用不完全类型'类测试'
int get()const noexcept(noexcept(std :: declval< test>
类测试{
这是根据标准的预期行为还是GCC(4.8.0)中的错误?