noexcept运算符递归使用:GCC可编译,Clang/MSVC报错,哪个符合C++标准?
关于C++递归noexcept声明的编译器行为疑问
我正在通过经典C书籍列表学习C,出于学术研究目的编写了如下代码示例,该代码可在GCC中编译通过,但无法在Clang和MSVC中编译。
struct C { static bool f() noexcept(!noexcept(C::f())) { return true; } };
各编译器的表现如下:
- GCC:可正常编译该代码
- MSVC:报错信息如下
<source>(2): fatal error C1202: recursive type or function dependency context too complex - Clang:报错信息如下
<source>:2:40: error: exception specification is not available until end of class definition static bool f() noexcept(!noexcept(C::f()))
我的疑问是:这些编译器中哪个(如果有的话)的行为符合C++标准?
内容的提问来源于stack exchange,提问作者user19946454
相关产品推荐
相关产品推荐

