C3520参数包必须扩展 - 使用' variadic的行为不正确。
在使用Microsoft Visual C ++编译器15.9.28307.1300(AMD64)和C ++ 17标准I标准i使用Microsoft Visual C ++编译器使用QT 5.12编译下面的代码时
错误c3520:'args':必须在此上下文中扩展参数包 注意:请参阅类模板实例化的参考 'helper< args ...>'被编译
template<typename T>
struct Base {
void operator()(const T& arg){}
};
template <typename... Args>
class Helper : Base<Args>... {
public:
using Base<Args>::operator()...;
};
是MSVC的错误吗?有什么已知的解决方法吗?相同的代码使用clang在macOS上编译。
While compiling the code below with Qt 5.12 using Microsoft Visual C++ Compiler 15.9.28307.1300 (amd64) and c++17 standard I get the following error:
error C3520: 'Args': parameter pack must be expanded in this context
note: see reference to class template instantiation
'Helper<Args...>' being compiled
template<typename T>
struct Base {
void operator()(const T& arg){}
};
template <typename... Args>
class Helper : Base<Args>... {
public:
using Base<Args>::operator()...;
};
Is this a bug with msvc? Is there any known workaround? The same code compiles on macOS using clang.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
作为可变参数
using
(C++17) 的解决方法,您可以使用递归方式:演示
As workaround to variadic
using
(C++17), you might use the recursive way:Demo