心渐渐失空

导航

c++标准模板库algorithm头文件中accumulate算法的代码

template <typename T>
T algorithm(T* start, T* end, T total)//把[start, end)标记范围内所有元素累加到total中
{
    while (start != end)
    {
        total += *(start++);
    }
    return total;
}

posted on 2015-10-30 14:44  心渐渐失空  阅读(1045)  评论(0)    收藏  举报