c++ - 绑定可变参数函数 C++
问题描述
假设我有这样的功能:
template <typename... T>
void sum(int start, T... next);
我想绑定这个。我该怎么做?
更准确地说,如果函数有固定数量的参数,它看起来像:
void sum(int start, int next); // function signature
// ...
auto binded_sum = std::bind(sum, 0, std::placeholders::_1);
现在我将如何“占位”可变数量的参数?
解决方案
这些方面的东西:
auto binded_sum = [](auto... next) { sum(0, next...); };
推荐阅读
- math - 将加速度计数据转换为对象空间
- google-data-studio - 在 Data Studio 中计算平均每周流量
- join - 在多个条件下加入每个条件结果
- apache-spark - Kafka Stream 到 Spark Stream python
- reporting-services - Windows 2016 服务器上的 SSRS 导出为 PDF 字符间距问题
- android - 平板电脑的通知集大图显示质量低
- php - 从 PHP 调用 Python 脚本不起作用
- javascript - 如何让 localStorage 在 vue 测试中工作
- jquery - jquery最后一个兄弟再次来到第一个兄弟?
- reactjs - 使用 Apollo Client GraphQL 查询和修改表单