到现在为止,我会猜到

double mean(ConstIterator startIt, ConstIterator endIt);

是用于计算存储在std集合中的值的集合平均值的函数的体面签名。

但是对于C++ 11,我们同时拥有lamda和for val : Col

这种功能的最佳实践签名是什么?

最佳答案

在获得范围之前,就采用值集合的函数而言,什么都不会改变。

但是,除非该函数特定于某些类型,否则通常以通用方式实现这种事情:

template<typename Iterator, typename Sentinel>
auto mean(Iterator begin, Sentinel end) { // C++14 deduced return type
  // ...
}

关于c++ - C++ 11 esque签名的函数,用于计算值的标量,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31328457/

10-11 22:46
查看更多