struct X
{
void f() noexcept(noexcept(g()));
void g() noexcept;
};
在 vc++ 和 clang 中,这可以工作,但 gcc 会提示:
source_file.cpp:6:34: error: ‘g’ was not declared in this scope
void f() noexcept(noexcept(g()));
^
我认为这是 gcc 中的一个错误,而不是其他 gcc 中的功能。这是正确的吗?
最佳答案
您的评估是 correct
Within the class member-specification, the class is regarded as complete within function bodies, default arguments, noexcept-specifiers, and default member initializers (including such things in nested classes). Otherwise it is regarded as incomplete within its own class member-specification.
在完整类型的范围内,g
应该由 unqualified name lookup 找到。
关于c++ - 这个 noexcept 声明有效吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55677543/