这是解决 GCC "sorry, unimplemented: cannot expand ‘NEXT ...’ into a fixed-length argument list"错误的好方法吗?

Is ther a good workaround for GCC's "sorry, unimplemented: cannot expand ‘NEXT ...’ into a fixed-length argument list" error?

本文关键字:argument list fixed-length into 错误 方法 NEXT sorry GCC 解决 unimplemented      更新时间:2023-10-16

可能重复:
可变模板的GCC错误:“抱歉,未实现:无法扩展';标识符…#39;进入固定长度的参数列表";

我有这个代码,它会产生标题中显示的错误消息:

#include <iostream>
template <int FIRST, int... NEXT>
struct Test {
    static const int VALUE = FIRST + Test<NEXT...>::VALUE;
};
template <int FIRST>
struct Test<FIRST> {
    static const int VALUE = FIRST;
};
int main() {
    std::cout << Test<1, 2, 3>::VALUE << std::endl; // print "6"
    return 0;
}

有没有什么简单的变通方法可以让它在GCC中编译而不改变它的功能?

更新GCC。

相关文章: