的boost docs給這個作爲boost::accumulate
如何使用的一個示例:在C++ 11中更加優雅的助推積累?
// The data for which we wish to calculate statistical properties:
std::vector<double> data(/* stuff */);
// The accumulator set which will calculate the properties for us:
accumulator_set< double, features< tag::tail<left> > > acc(
tag::tail<left>::cache_size = 4);
// Use std::for_each to accumulate the statistical properties:
std::for_each(data.begin(), data.end(), bind<void>(ref(acc), _1));
是否有寫這個代碼與C++十四分之十一基於範圍環路或lambda表達式更優雅的方式?
這段代碼應該做什麼? –
跟蹤最小的4個值。尾巴描述在http://www.boost.org/doc/libs/1_60_0/doc/html/accumulators/user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.tail我的問題是更一般地關於累加器框架和for_each線儘管 –