假设我有一个这样的函数:
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);
现在,我将如何“占据”可变数量的参数?
值得一提的是,C ++ 20也std::bind_front
正是为此目的而提供的:
auto bound_sum = std::bind_front(sum, 0);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句