Boost logo

Boost :

Subject: [boost] Can't compile valarray.cpp - any ideas why?
From: Chris Cooper (chris.cooper_at_[hidden])
Date: 2014-04-23 19:13:23


On my Mac (OSX 10.9.2, running clang++ "Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)”), I can’t get the libs/accumulators/test/valarray.cpp regression test to compile. The error it gives is of course lengthy, but goes something like this:

In file included from valarray.cpp:18:
../../../boost/accumulators/statistics/weighted_mean.hpp:73:13: error: no matching constructor for initialization of 'result_type' (aka 'valarray<typename divides<left_value_type, const double>::result_type>')
        : mean(
../../../boost/accumulators/framework/depends_on.hpp:319:17: note: in instantiation of function template specialization 'boost::accumulators::impl::immediate_weighted_mean_impl<SNIP>' requested here

        : Accumulator(args)
../../../boost/accumulators/framework/depends_on.hpp:252:29: note: in instantiation of function template specialization 'boost::accumulators::detail::accumulator_wrapper<SNIP>' requested here

        return type(args, next_build_acc_list::call(args, fusion::next(f), l));
../../../boost/accumulators/framework/depends_on.hpp:252:56: note: in instantiation of function template specialization 'boost::accumulators::detail::build_acc_list<SNIP>' requested here

        return type(args, next_build_acc_list::call(args, fusion::next(f), l));
../../../boost/accumulators/framework/depends_on.hpp:271:51: note: in instantiation of function template specialization 'boost::accumulators::detail::build_acc_list<SNIP>' requested here

        return meta::make_acc_list<Sequence>::call(args, fusion::begin(seq), fusion::end(seq));
../../../boost/accumulators/framework/accumulator_set.hpp:159:21: note: in instantiation of function template specialization 'boost::accumulators::detail::make_acc_list<SNIP>' requested here

        detail::make_acc_list(
valarray.cpp:150:78: note: in instantiation of function template specialization 'boost::accumulators::accumulator_set<SNIP>' requested here

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/valarray:806:5: note: candidate constructor not viable: no known conversion from 'typename result<SNIP>' to 'const std::__1::valarray<double>' for 1st argument
    valarray(const valarray& __v);

That last little bit makes it look like “result_type mean” is of type valarray<double> and boost is trying to pass a valarray<int> into its copy constructor and not succeeding.

I’ve narrowed down the offending code (in valarray.cpp) and this is the code that won’t compile:

    typedef std::valarray<int> sample_t;

    typedef boost::accumulators::stats<boost::accumulators::tag::weighted_mean(boost::accumulators::immediate)> mystats;

    boost::accumulators::accumulator_set<sample_t, mystats, int> acc2;

Which is basically the same as:

    sample_t s;

    typedef boost::numeric::functional::multiplies<sample_t, int>::result_type weighted_sample;

    typedef boost::numeric::functional::fdiv<weighted_sample, int>::result_type result_type;

    result_type mean(s);

which also doesn’t compile and gives a pretty-much-identical error message.

I’m completely unfamiliar with the boost accumulators code, any suggestions on why this is failing, and what I can do to patch valarray.cpp so the regression test will compile?

Thanks,

Chris


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk