Boost logo

Boost Users :

Subject: [Boost-users] [Accumulators] Errors compiling the "Hello, World!" example
From: Marco Guazzone (marco.guazzone_at_[hidden])
Date: 2010-01-10 18:05:57


Hello!

I'm new to Accumulators.
I've tried to compile the "Hello, World!" example (found in the User
Guide) but it fails:

--- [error] ---
$ g++ -ansi -Wall -o accumulators_test1 accumulators_test1.cpp

/usr/include//boost/accumulators/statistics_fwd.hpp: In function ‘int main()’:
/usr/include//boost/accumulators/statistics_fwd.hpp:87: error:
‘template<int N> struct boost::accumulators::tag::moment’ is not a
function,
/usr/include//boost/accumulators/statistics/moment.hpp:104: error:
conflict with ‘template<int T2, class Arg1, class A0, class A1, class
A2, class A3, class A4, class A5, class A6, class A7, class A8, class
A9, class A10, class A11, class A12, class A13, class A14> typename
boost::accumulators::detail::extractor_result<Arg1,
boost::accumulators::tag::moment<T2> >::type
boost::accumulators::extract::moment(const Arg1&, const A0&, const
A1&, const A2&, const A3&, const A4&, const A5&, const A6&, const A7&,
const A8&, const A9&, const A10&, const A11&, const A12&, const A13&,
const A14&)’
accumulators_test1.cpp:22: error: in call to ‘moment’
--- [/error] ---

My system is: Fedora 12 x86_64 -- GCC 4.4.2 20091222 (Red Hat
4.4.2-20) -- Boost 1.39
(also tried with the latest Boost trunk)

Just for the sake of completeness, here below is the code stored in
the "accumulators_test1.cpp" file

--- [code] ---
#include <iostream>
#include <boost/accumulators/accumulators.hpp>
#include <boost/accumulators/statistics/stats.hpp>
#include <boost/accumulators/statistics/mean.hpp>
#include <boost/accumulators/statistics/moment.hpp>
using namespace boost::accumulators;

int main()
{
    // Define an accumulator set for calculating the mean and the
    // 2nd moment ...
    accumulator_set<double, stats<tag::mean, tag::moment<2> > > acc;

    // push in some data ...
    acc(1.2);
    acc(2.3);
    acc(3.4);
    acc(4.5);

    // Display the results ...
    std::cout << "Mean: " << mean(acc) << std::endl;
    std::cout << "Moment: " << moment<2>(acc) << std::endl;

    return 0;
}
--- [/code] ---

Where I am wrong?

Thank you very much for any help!!

Best,

-- Marco


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