【发布时间】:2014-09-11 22:10:32
【问题描述】:
我正在寻找将范围转换为整数类型的模板函数。它看起来像这样:
template<typename InputIterator, typename IntegralType>
IntegralType convert(InputIterator first, InputIterator last)
{
...
}
它可以这样使用:
vector<char> buf;
int tag=convert<int>(buf.begin(), buf.end());
有没有标准的方法来做到这一点?以前有人这样做过吗?
谢谢
【问题讨论】:
-
范围的内容如何映射到积分输出?
-
在<algorithm>和<numeric>中定义了很多将范围转换为数字的标准方法
-
从值范围到单个值的映射是什么?和?意思是?中位数?标准差?最大限度?分钟?
标签: c++ iterator type-conversion