【发布时间】:2017-11-02 11:38:09
【问题描述】:
以下结构化绑定代码在 clang 上运行良好。 Live demo
但是,它在 GCC 编译器上失败了。 Live demo
#include <iostream>
struct st {
bool b = true;
};
template <class T>
bool func() noexcept {
auto [a] = T{};
return a;
}
int main() {
const bool b1 = func<st>();
}
为什么结构化绑定在 GCC 上会失败?
【问题讨论】:
-
什么是预期结果,什么是实际结果?
-
因为 GCC 在其实现中存在需要修复的错误。这就是你问的问题的答案。这不是一个过于有用的问题。但是,您可以改写它以使其更有用。
-
这个问题...与 gcc 错误密切相关?
-
编译器说“失败”?