|
Boost Users : |
Subject: [Boost-users] Boost.Accumulators: how to use with object data members?
From: Joost Kraaijeveld (J.Kraaijeveld_at_[hidden])
Date: 2009-04-12 09:31:48
Hi,
Is it possible to use Boost.Accumulators on data members of a class,
with a UnaryFunction or Lamba function ?
E.g.
struct Data
{
double data;
};
vector<Data> v;
// Insert some Data objects here....
accumulator_set< double, features< tag::variance > > acc;
acc = for_each( v.begin(), v.end(), ??????? );
cout << "Variance: " << variance(acc) << std::endl;
where ???? is an arbitrary UnaryFunction or Lamda function something
like "bind<void>( ref(acc), bind(&Data::data, _1)) )"
(which did not do the trick)
TIA
-- Groeten, Joost Kraaijeveld Askesis B.V. Molukkenstraat 14 6524NB Nijmegen tel: 024-3888063 / 06-51855277 fax: 024-3608416 web: www.askesis.nl
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net