c++ - 将参数包与 std::function 一起使用时出错
问题描述
我有这个代码:
#include <functional>
template<class T, class U>
void f(std::function<T(U)> g) {};
int main() {
auto h = [](int x) {return x;};
f<int, int>(h);
}
此代码有效。但是当我使用参数包(下面的代码)时,它失败了......为什么?
#include <functional>
template<class T, class...U>
void f(std::function<T(U...)> g) {};
int main() {
auto h = [](int x) {return x;};
f<int, int>(h);
}
使用std::function<int(int)>
而不是auto
使其与参数包一起使用。
解决方案
推荐阅读
- r - R webscraping一个缓慢/负担过重的(?)网站
- java - 如何在`OnClick`方法中使用`Arraylist`?
- continuous-integration - Bitbucket Pipeline:在 pdfLaTeX 之后存储 .pdf 工件
- python - 带有时区的时间戳到熊猫日期时间
- ms-access - 使用记录号将链接的 DBF 转换为 Access
- git - 特定日期的变更日志
- r - R - 根据 R 中其他列的值设置组值
- c# - 绑定 AuthenticationConfig 抛出异常
- c# - 使用实体框架在数据库中插入记录的问题
- java - 如何从 ArrayList 中删除一个项目
>