Jan*_*tke 5 c++ clang language-lawyer compiler-bug noexcept
我有以下代码:
struct S {
// conditional noexcept specification which depends on noexceptness of foo()
void bar() noexcept(noexcept(foo()));
// conditional noexcept specification (true)
void foo() noexcept(true);
};
Run Code Online (Sandbox Code Playgroud)
Clang 拒绝此代码,但 GCC 允许它(https://godbolt.org/z/nxqa5Tr1x):
<source>:2:34: error: exception specification is not available until end of class definition
2 | void bar() noexcept(noexcept(foo()));
|
Run Code Online (Sandbox Code Playgroud)
替换noexcept(true)为noexcept两个编译器都允许
noexcept(true)失败但是noexcept成功?注意:这个例子显然是最小的。我的实际用例是,我有一个clear()成员函数,仅在自定义容器中为noexceptif clear_impl()is 。noexcept
| 归档时间: |
|
| 查看次数: |
124 次 |
| 最近记录: |