|
Boost-Commit : |
From: eric_at_[hidden]
Date: 2008-06-19 22:34:00
Author: eric_niebler
Date: 2008-06-19 22:34:00 EDT (Thu, 19 Jun 2008)
New Revision: 46540
URL: http://svn.boost.org/trac/boost/changeset/46540
Log:
alternate way to use an accumulator with an algorithm
Text files modified:
trunk/libs/accumulators/example/main.cpp | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
Modified: trunk/libs/accumulators/example/main.cpp
==============================================================================
--- trunk/libs/accumulators/example/main.cpp (original)
+++ trunk/libs/accumulators/example/main.cpp 2008-06-19 22:34:00 EDT (Thu, 19 Jun 2008)
@@ -7,6 +7,8 @@
#include <iostream>
#include <algorithm>
+#include <boost/ref.hpp>
+#include <boost/bind.hpp>
#include <boost/array.hpp>
#include <boost/foreach.hpp>
#include <boost/accumulators/accumulators.hpp>
@@ -47,6 +49,11 @@
// time, and returns a copy of the accumulator.
acc = std::for_each(data.begin(), data.end(), acc);
+ // The following would be equivalent, and could be more efficient
+ // because it doesn't pass and return the entire accumulator set
+ // by value.
+ //std::for_each(data.begin(), data.end(), bind<void>(ref(acc), _1));
+
std::cout << " min(acc) = " << (min)(acc) << std::endl;
std::cout << " mean(acc) = " << mean(acc) << std::endl;
@@ -59,7 +66,7 @@
///////////////////////////////////////////////////////////////////////////////
// example2
//
-// Calculate some tail statistics. This demonstrates how to specify
+// Calculate some tail statistics. This demonstrates how to specify
// constructor and accumulator parameters. Note that the tail statistics
// return multiple values, which are returned in an iterator_range.
//
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk