c++风格的函数签名,用于计算一组值的标量
C++11esque signature of a function computing a scalar of a collection of values
到目前为止,我已经猜到了
double mean(ConstIterator startIt, ConstIterator endIt);
对于计算STD集合中存储的一组值的均值的函数来说,是一个不错的签名。
但是在c++ 11中,我们有lambda和for val : Col
。
在得到范围之前,函数接受值的集合方面不会有太大的变化。
然而,除非函数是特定于某些类型的,否则通常这类事情是一般实现的:
template<typename Iterator, typename Sentinel>
auto mean(Iterator begin, Sentinel end) { // C++14 deduced return type
// ...
}
相关文章:
- 在 c++ 中拥有一组结构的正确方法是什么?
- 有哪些有效的方法可以消除一组 100 万个字符串>重复数据?
- 程序以使用 C++ 中的 while 循环查找一组数字的最小值
- 一组值的零开销下标运算符
- 使用一组结构,避免在一组结构中出现重复的结构
- CMake:我们可以为一组不形成可执行文件或库的特定文件指定包含目录吗?
- 合并一组模板专用化
- 如何更好地检查两个 char 变量是否在一组值中?
- C++有没有办法强制重写一组方法,如果其中一个方法在子类中具有重写?
- 给定一个枢轴点,按照它们与枢轴点构成的角度递增顺序对一组点进行排序
- 如何从一组变量中查找最低值
- 如何根据对的第二个元素对 STL c++ 中的一组对进行排序?
- 如何通过查找迭代器结果分配给一组对的元素
- 读取一组用户输入,按升序排序,然后打印结果
- 如何从一组具有从左到右优先级的整数值创建有序整数键?
- 在 c++ 中定义一组 set 的迭代器
- 使用 C++20 概念强制类实现一组方法
- 这是定义一组递归规则的正确方法吗?
- C++ 将一组对象传递给抽象类的成员函数
- c++风格的函数签名,用于计算一组值的标量