Ale*_*lex 6 c++ exception language-lawyer noexcept
我正在使用此处列出的书籍学习 C++ 。我编写了以下示例(纯粹出于学术原因),该示例使用 GCC 进行编译,但不使用 Clang 和 MSVC 进行编译。演示。
struct C {
static bool f() noexcept(!noexcept(C::f()))
{
return true;
}
};
Run Code Online (Sandbox Code Playgroud)
正如我们在这里看到的,上面的示例使用 gcc 进行编译,但不使用 msvc 和 clang 进行编译。
所以我的问题是哪个编译器就在这里(如果有的话)。
GCC 编译了这个。
MSVC 说:
<source>(2): fatal error C1202: recursive type or function dependency context too complex
Run Code Online (Sandbox Code Playgroud)
铿锵 说:
<source>:2:40: error: exception specification is not available until end of class definition
static bool f() noexcept(!noexcept(C::f()))
Run Code Online (Sandbox Code Playgroud)