0

在定义带有函数参数的函数时,我应该std::function通过复制、引用还是 const 引用来接收 lambda/?

还是三个都行?

4

1 回答 1

0

我会选择 const ref。const 是因为函数不应该被更改,而 ref 是因为接受参数的函数不必检查 null。

但不要相信我的话,这将取决于具体情况。这是一个提供其他观点的重复帖子:

我应该通过 const-reference 传递 std::function 吗?

于 2014-06-02T05:51:25.960 回答