Related
I have a small sm with just one state for now.
I want from within the state, to access some data that is received and stored by the sm on construction:
struct data {
std::string m_ip;
data(const char* ip)
: m_ip(ip)
{
}
};
namespace sc = boost::statechart;
struct s1;
struct sm : sc::state_machine<sm, s1> {
data* m_data;
sm(data* d)
: m_data { d }
{
}
};
struct s1 : sc::simple_state<s1, sm> {
s1()
{
std::cout << context<sm>().m_data->m_ip; // assertion
}
};
int main()
{
data _data("192.168.1.1");
sm _sm(&_data);
_sm.initiate();
return 0;
}
When I run this, I get the following error:
test: /usr/include/boost/statechart/simple_state.hpp:682: static OtherContext& boost::statechart::simple_state<MostDerived, Context, InnerInitial, historyMode>::context_impl_other_context::context_impl(State&) [with OtherContext = sm; State = boost::statechart::simple_state<s1, sm>; MostDerived = s1; Context = sm; InnerInitial = boost::mpl::list<mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>; boost::statechart::history_mode historyMode = (boost::statechart::history_mode)0]: Assertion `get_pointer( stt.pContext_ ) != 0' failed.
I don't understand why the context pointer is null.
I found my answer here.
It was staring me in the face, from the comment above the assertion:
// This assert fails when an attempt is made to access an outer
// context from a constructor of a state that is *not* a subtype of
// state<>. To correct this, derive from state<> instead of
// simple_state<>.
Not sure if this should be marked as duplicate as it is the same issue, but triggered a bit differently (the context is an outer state, not the state machine itself, as in my case).
I am using boost.type_erasure in my codebase. So far the experience,
given what it enables, has been very good.
I want to be able to forward-declare a " type-erased reference type" for my API. This leaves outside using and typedef because they do not allow
forward declarations.
For a value type everything is fine:
class any_game_state : public
boost::type_erasure::any<
boost::mpl::vector<has_enter<void ()>,
has_update<bool (std::chrono::milliseconds)>,
has_exit<int ()>,
has_get_resolution<std::pair<int, int> (),
const
boost::type_erasure::_self>,
has_get_position<std::pair<int, int> (),
const
boost::type_erasure::_self>,
has_get_scene_root<boost::any (), const
boost::type_erasure::_self>,
boost::type_erasure::copy_constructible<>,
boost::type_erasure::relaxed>> {
using base = boost::type_erasure::any<...identical_contents>;
using base::base;
};
But when I try to do the same for its corresponding reference, it is not working:
class any_game_state_ref : public
boost::type_erasure::any<
boost::mpl::vector<has_enter<void ()>,
has_update<bool (std::chrono::milliseconds)>,
has_exit<int ()>,
has_get_resolution<std::pair<int, int> (),
const
boost::type_erasure::_self>,
has_get_position<std::pair<int, int> (),
const
boost::type_erasure::_self>,
has_get_scene_root<boost::any (), const
boost::type_erasure::_self>,
boost::type_erasure::copy_constructible<>,
boost::type_erasure::relaxed>,
boost::type_erasure::_self&> {
using base = boost::type_erasure::any<...identical_contents>;
using base::base;
};
If I use using for the "reference type" everything works fine, but I lose the ability to forward-declare the reference type.
The error I get is the following:
In file included from src/barvie/controller/game_action_state.cpp:3:
In file included from /usr/local/include/boost/type_erasure/any_cast.hpp:24:
/usr/local/include/boost/type_erasure/any.hpp:1290:12: error: no type named 'type' in 'boost::disable_if, has_update >), boost::type_erasure::_self>, has_exit, has_get_resolution (), const boost::type_erasure::_self>, has_get_position (), const boost::type_erasure::_self>, has_get_scene_root, boost::type_erasure::copy_constructible, boost::type_erasure::relaxed, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::mpl::vector, has_update >), boost::type_erasure::_self>, has_exit, has_get_resolution (), const boost::type_erasure::_self>, has_get_position (), const boost::type_erasure::_self>, has_get_scene_root, boost::type_erasure::copy_constructible, boost::type_erasure::relaxed, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na> >, boost::is_const, mpl_::bool_, mpl_::bool_, mpl_::bool_ >, void>'
::type* = 0
~~~^~~~
../libbarvie/src/barvie/controller/any_game_state.hpp:95:17: note: in instantiation of member function 'boost::type_erasure::any, has_update >), boost::type_erasure::_self>, has_exit, has_get_resolution (), const boost::type_erasure::_self>, has_get_position (), const boost::type_erasure::_self>, has_get_scene_root, boost::type_erasure::copy_constructible, boost::type_erasure::relaxed, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::type_erasure::_self &>::any' requested here
using base::base;
^
src/barvie/controller/game_action_state.cpp:291:18: note: while substituting deduced template arguments into function template 'any_game_state_ref' [with Concept2 = boost::mpl::vector, has_update >), boost::type_erasure::_self>, has_exit, has_get_resolution (), const boost::type_erasure::_self>, has_get_position (), const boost::type_erasure::_self>, has_get_scene_root, boost::type_erasure::copy_constructible, boost::type_erasure::relaxed, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, Tag2 = boost::type_erasure::_self]
(this,
^
In file included from src/barvie/controller/game_action_state.cpp:3:
In file included from /usr/local/include/boost/type_erasure/any_cast.hpp:24:
/usr/local/include/boost/type_erasure/any.hpp:1323:12: error: no type named 'type' in 'boost::disable_if, has_update >), boost::type_erasure::_self>, has_exit, has_get_resolution (), const boost::type_erasure::_self>, has_get_position (), const boost::type_erasure::_self>, has_get_scene_root, boost::type_erasure::copy_constructible, boost::type_erasure::relaxed, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::mpl::vector, has_update >), boost::type_erasure::_self>, has_exit, has_get_resolution (), const boost::type_erasure::_self>, has_get_position (), const boost::type_erasure::_self>, has_get_scene_root, boost::type_erasure::copy_constructible, boost::type_erasure::relaxed, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na> >, boost::is_const, mpl_::bool_, mpl_::bool_, mpl_::bool_ >, void>'
::type = 0
~~~^~~~
../libbarvie/src/barvie/controller/any_game_state.hpp:95:17: note: in instantiation of member function 'boost::type_erasure::any, has_update >), boost::type_erasure::_self>, has_exit, has_get_resolution (), const boost::type_erasure::_self>, has_get_position (), const boost::type_erasure::_self>, has_get_scene_root, boost::type_erasure::copy_constructible, boost::type_erasure::relaxed, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::type_erasure::_self &>::any' requested here
using base::base;
^
src/barvie/controller/game_action_state.cpp:291:18: note: while substituting deduced template arguments into function template 'any_game_state_ref' [with Concept2 = boost::mpl::vector, has_update >), boost::type_erasure::_self>, has_exit, has_get_resolution (), const boost::type_erasure::_self>, has_get_position (), const boost::type_erasure::_self>, has_get_scene_root, boost::type_erasure::copy_constructible, boost::type_erasure::relaxed, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, Tag2 = boost::type_erasure::_self &]
(*this,
I found a solution. The solution is to give up on inherited constructors for the reference type, instead of the inherited constructor I used an equivalent by-hand inherited constructor. It seems that maybe something about templates mixed with inherited constructors did not play well:
template <class...Args>
any_game_state_ref(Args &&... args) : base(std::forward<Args>(args)...)
{}
This did the trick and now I can forward declare type erased references also.
I'm using gdb-7.5, on RHEL 6, compiled with gcc-4.7.2. I'm trying to
write a pretty printer for boost::multi_index and ran into problems
with gdb.lookup_type.
Below given code has the following declaration.
TestSet ts;
Now, at the gdb command prompt, I'm performing the following
operations (in python)
gdb >> python
set_value = gdb.parse_and_eval('ts')
set_type = set_value.type.strip_typedefs()
t1 = set_type.template_argument(0) # Test
t2 = set_type.template_argument(1) # boost::mult_index::indexed_by ....
t3 = set_type.template_argument(2) # std::allocator<Test>
node_type = gdb.lookup_type('boost::multi_index::detail::multi_index_node_type < %s, %s, %s >::type' % (t1, t2, t3))
base = gdb.lookup_type ('boost::multi_index::detail::multi_index_base_type < %s, %s, %s >::type' % (t1, t2, t3))
allocator = gdb.lookup_type('boost::detail::allocator::rebind_to<%s, %s>::type' % (t3, node_type))
end
I'm getting the node_type correctly. But gdb is unable to get types
for 'base' and 'allocator'.
The error for base
Traceback (most recent call last):
File "<string>", line 1, in <module>
gdb.error: No type named boost::detail::multi_index_base_type < Test,
boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::member<Test,
std::basic_string<char, std::char_traits<char>, std::allocator<char>
>, &Test::s>, mpl_::na, mpl_::na>
, boost::multi_index::ordered_unique<boost::multi_index::tag<int,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::multi_i
ndex::member<Test, int, &Test::i>, mpl_::na>,
boost::multi_index::ordered_unique<boost::multi_index::member<Test,
float, &Test::f>, mpl_::na, mpl_::na>, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na
, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>,
std::allocator<Test> >::type.
Error while executing Python code.
and a similar error for 'allocator'.
As boost::multi_index_container is derived from
boost::detail::multi_index_base_type, I'm expecting gdb to return a
valid type for the same.
Am I missing something here. ?
I've posted the same question in gdb mailing list but there was no answer.
The code:
#include <string>
using namespace std;
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/key_extractors.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/sequenced_index.hpp>
#include <boost/multi_index/random_access_index.hpp>
using namespace boost::multi_index;
using namespace boost;
struct Test
{
Test (const string& ps, int pi, float pf)
: s(ps), i(pi), f(pf)
{
}
string s;
int i;
float f;
};
typedef multi_index_container <
Test,
indexed_by <
ordered_unique < member <Test, string, &Test::s> >,
ordered_unique < tag<int>, member <Test, int, &Test::i> >,
ordered_unique < member <Test, float, &Test::f> >
>
> TestSet;
int main(void)
{
TestSet ts;
ts.insert(Test("ABCDEF", 10, 1.0f));
ts.insert(Test("Some String", 5, 2.0f));
ts.insert(Test("PQRXYZ", 7, 0.3f));
return 0;
}
Surya
I would start by trying to find out whether this type actually does exist. One way would be to dig through the "readelf -wi" output. This dumps the DWARF information for your program. However, it is likely to be very large, and so it may take a while.
If it exists in the DWARF then I would debug gdb to see what is going wrong.
If it isn't in the DWARF then it may be a compiler error, or just wrong compilation arguments.
I've got a strange problem with templates and namespaces...
I have the following code which compiles fine..
using namespace boost::multi_index;
template < typename OT, typename KT, KT (OT::* KM)() const, typename KC, typename CMP >
class OrderBook
{
public:
OrderBook() {}
~OrderBook() {}
typedef multi_index_container<
OT,
indexed_by<
ordered_unique<
const_mem_fun< OT, KT, KM >,
KC
>,
ordered_unique<
identity< OT >,
CMP
>
>
> Container;
typedef typename Container::template nth_index< 0 >::type index_0;
typedef typename Container::template nth_index< 1 >::type index_1;
typedef typename index_0::const_iterator const_iterator_0;
typedef typename index_1::const_iterator const_iterator_1;
const_iterator_0 begin0() const { return _container.get<0>().begin(); }
const_iterator_0 end0() const { return _container.get<0>().end(); }
public:
Container _container;
};
However, due to a namespace collision when I insert this code into another project I have to have... (Notice how I've had to remove the using namespace boost::multi_index and manually specify it where needed
template < typename OT, typename KT, KT (OT::* KM)() const, typename KC, typename CMP >
class OrderBook
{
public:
OrderBook() {}
~OrderBook() {}
typedef boost::multi_index::multi_index_container<
OT,
boost::multi_index::indexed_by<
boost::multi_index::ordered_unique<
boost::multi_index::const_mem_fun< OT, KT, KM >,
KC
>,
boost::multi_index::ordered_unique<
boost::multi_index::identity< OT >,
CMP
>
>
> Container;
typedef typename Container::template nth_index< 0 >::type index_0;
typedef typename Container::template nth_index< 1 >::type index_1;
typedef typename index_0::const_iterator const_iterator_0;
typedef typename index_1::const_iterator const_iterator_1;
const_iterator_0 begin0() const { return _container.get<0>().begin(); }
const_iterator_0 end0() const { return _container.get<0>().end(); }
public:
Container _container;
};
Which gives me the following error from g++.
In member function 'typename boost::multi_index::multi_index_container<OT, boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::const_mem_fun<OT, KT, KM>, KC, mpl_::na>, boost::multi_index::ordered_unique<boost::multi_index::identity<Value>, CMP, mpl_::na>, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, std::allocator<_CharT> >::nth_index<0>::type::const_iterator OrderBook<OT, KT, KM, KC, CMP>::begin0() const':
error: expected primary-expression before ')' token
In member function 'typename boost::multi_index::multi_index_container<OT, boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::const_mem_fun<OT, KT, KM>, KC, mpl_::na>, boost::multi_index::ordered_unique<boost::multi_index::identity<Value>, CMP, mpl_::na>, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, std::allocator<_CharT> >::nth_index<0>::type::const_iterator OrderBook<OT, KT, KM, KC, CMP>::end0() const':
error: expected primary-expression before ')' token
Sorry for the long error messages, I did consider cleaning them up but I thought I'd better leave them intact in case I removed something crucial.
I tried this...
typedef typename Container::template boost::multi_index::nth_index< 0 >::type index_0;
typedef typename Container::template boost::multi_index::nth_index< 1 >::type index_1;
and it just made g++ even madder :(
Any ideas?
Prefix get<0>() with template:
const_iterator_0 begin0() const { return _container.template get<0>().begin(); }
const_iterator_0 end0 () const { return _container.template get<0>().end(); }
Similar to typename for dependent types, dependent templates have to be prefixed by template:
struct X {
template<class T> void f();
};
template<class T>
void test() {
T::f<int>(); // ill-formed
T::template f<int>(); // ok
}
// ...
test<X>();
And for the curious, that is §14.2/4:
When the name of a member template
specialization appears after . or ->
in a postfix-expression, or after
nested-name-specifier in a
qualified-id, and the
postfix-expression or qualified-id
explicitly depends on a
template-parameter (14.6.2), the
member template name must be prefixed
by the keyword template. Otherwise the
name is assumed to name a
non-template.
Maybe I can guess that some of these functions are not in the boost::multi_index namespace: indexed_b, ordered_unique, const_mem_fun, or identity
I'm trying to compile this example
But that one header isn't enough and I've already spent half an hour trying to clobber all of the errors. Why aren't the required includes specified?
I did this:
#include <boost/accumulators/statistics/weighted_p_square_cumulative_distribution.hpp>
#include <vector>
#include <boost/accumulators/accumulators.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/random/lagged_fibonacci.hpp>
#include <boost/random/normal_distribution.hpp>
#include <boost/random/variate_generator.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/fusion/support/void.hpp>
#include <boost/accumulators/framework/depends_on.hpp>
using namespace boost::accumulators;
using namespace boost;
int main() {
// tolerance in %
double epsilon = 4;
typedef accumulator_set<double, stats<tag::weighted_p_square_cumulative_distribution>, double > accumulator_t;
accumulator_t acc_upper(tag::weighted_p_square_cumulative_distribution::num_cells = 100);
accumulator_t acc_lower(tag::weighted_p_square_cumulative_distribution::num_cells = 100);
// two random number generators
double mu_upper = 1.0;
double mu_lower = -1.0;
boost::lagged_fibonacci607 rng;
boost::normal_distribution<> mean_sigma_upper(mu_upper,1);
boost::normal_distribution<> mean_sigma_lower(mu_lower,1);
boost::variate_generator<boost::lagged_fibonacci607&, boost::normal_distribution<> > normal_upper(rng, mean_sigma_upper);
boost::variate_generator<boost::lagged_fibonacci607&, boost::normal_distribution<> > normal_lower(rng, mean_sigma_lower);
for (std::size_t i=0; i<100000; ++i)
{
double sample = normal_upper();
acc_upper(sample, weight = std::exp(-mu_upper * (sample - 0.5 * mu_upper)));
}
for (std::size_t i=0; i<100000; ++i)
{
double sample = normal_lower();
acc_lower(sample, weight = std::exp(-mu_lower * (sample - 0.5 * mu_lower)));
}
typedef iterator_range<std::vector<std::pair<double, double> >::iterator > histogram_type;
histogram_type histogram_upper = weighted_p_square_cumulative_distribution(acc_upper);
histogram_type histogram_lower = weighted_p_square_cumulative_distribution(acc_lower);
// Note that applaying importance sampling results in a region of the distribution
// to be estimated more accurately and another region to be estimated less accurately
// than without importance sampling, i.e., with unweighted samples
for (std::size_t i = 0; i < histogram_upper.size(); ++i)
{
// problem with small results: epsilon is relative (in percent), not absolute!
// check upper region of distribution
if ( histogram_upper[i].second > 0.1 )
BOOST_CHECK_CLOSE( 0.5 * (1.0 + erf( histogram_upper[i].first / sqrt(2.0) )), histogram_upper[i].second, epsilon );
// check lower region of distribution
if ( histogram_lower[i].second < -0.1 )
BOOST_CHECK_CLOSE( 0.5 * (1.0 + erf( histogram_lower[i].first / sqrt(2.0) )), histogram_lower[i].second, epsilon );
}
}
And I got these errors:
In file included from /opt/local/include/boost/accumulators/statistics/weighted_p_square_cumulative_distribution.hpp:17,
from a.cc:1:
/opt/local/include/boost/accumulators/framework/extractor.hpp: In instantiation of 'boost::accumulators::detail::accumulator_set_result<boost::accumulators::accumulator_set<double, boost::accumulators::stats<boost::accumulators::tag::weighted_p_square_cumulative_distribution, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, double>, boost::accumulators::tag::weighted_p_square_cumulative_distribution>':
/opt/local/include/boost/mpl/eval_if.hpp:38: instantiated from 'boost::mpl::eval_if<boost::accumulators::detail::is_accumulator_set<boost::accumulators::accumulator_set<double, boost::accumulators::stats<boost::accumulators::tag::weighted_p_square_cumulative_distribution, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, double> >, boost::accumulators::detail::accumulator_set_result<boost::accumulators::accumulator_set<double, boost::accumulators::stats<boost::accumulators::tag::weighted_p_square_cumulative_distribution, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, double>, boost::accumulators::tag::weighted_p_square_cumulative_distribution>, boost::accumulators::detail::argument_pack_result<boost::accumulators::accumulator_set<double, boost::accumulators::stats<boost::accumulators::tag::weighted_p_square_cumulative_distribution, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, double>, boost::accumulators::tag::weighted_p_square_cumulative_distribution> >'
/opt/local/include/boost/accumulators/framework/extractor.hpp:57: instantiated from 'boost::accumulators::detail::extractor_result<boost::accumulators::accumulator_set<double, boost::accumulators::stats<boost::accumulators::tag::weighted_p_square_cumulative_distribution, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, double>, boost::accumulators::tag::weighted_p_square_cumulative_distribution>'
a.cc:47: instantiated from here
/opt/local/include/boost/accumulators/framework/extractor.hpp:36: error: no type named 'result_type' in 'struct boost::fusion::void_'
a.cc: In function 'int main()':
a.cc:47: error: no match for call to '(const boost::accumulators::extractor<boost::accumulators::tag::weighted_p_square_cumulative_distribution>) (main()::accumulator_t&)'
a.cc:48: error: no match for call to '(const boost::accumulators::extractor<boost::accumulators::tag::weighted_p_square_cumulative_distribution>) (main()::accumulator_t&)'
The examples shown in the docs are extracted from the library's unit tests. Take a look at libs/accumulators/test/weighted_p_square_cum_dist.cpp
error: no type named ‘result_type’ in ‘struct boost::fusion::void_’
I am sorry i can't provide a clear solution, but i hope i can help figure out what the problem is. Boost fusion enables you to build struct-equivalent objects where fields can be accessed using template arguments. Why am i telling you this ? Because the error you get is typically the error you get when trying to access a field that does not exist inside a fusion-struct.
These errors are generated by the following lines :
accumulator_t acc_upper(tag::weighted_p_square_cumulative_distribution::num_cells = 100);
accumulator_t acc_lower(tag::weighted_p_square_cumulative_distribution::num_cells = 100);
I am pretty sure the errors disappear if you remove the arguments of the constructor
accumulator_t acc_upper;
accumulator_t acc_lower;
I don't know much about boost accumulators, but the error may come from two causes : either your definition of accumulator_set is incorrect (is there a difference between "stats", which you use, and "features", which is suggested in boost accumulator documentation ?), or your definition of the argument used in the constructor is (incorrect). Find out which and you're likely to have solved your compilation error.
Use boost's bcp --list to make a list of dependencies, then you can be sure you're including all of them.
Unfortunately you don't show the compile errors you get, so I'll try a shot in the dark:
Did you use
using namespace boost::accumulators;
in your code? Most examples require this for brevity.
Edit:
Now that you posted your code (and I checked with the code sample from the link, too) it looks to me the example is broken. The key error seems to be:
error: no type named ‘result_type’ in ‘struct boost::fusion::void_’
But as I have no experience with boost::accumulators I'll have to give up here :-(
Maybe you can contact the author of boost::accumulators and let him know that the example is not compiling out of the box. He should be able to fix the example. And you might even get credit for spotting the problem :-)
Just ran into this problem. The solution for me was
#include <boost/accumulators/statistics/stats.hpp>