Boost logo

Boost :

Subject: [boost] [MSM] passing constructor arguments to frontend as reference.
From: Richard Szabo (sz.richard_at_[hidden])
Date: 2010-05-06 11:47:19


Hi, All

we might found a problem when passing constructor arguments to the
front end in case constructor arguments are passed by reference.
In that case you do not pass the argument as reference in the first
place rather copy construct a new object and pass that object as
reference to the front end.
We looked into the preprocessor code which we believe verified our assumption:

(code snippet only contains the first part with one constructor argument!)

template < class ARG0>
state_machine<Derived,HistoryPolicy,CompilePolicy >( ARG0 t0 )
:Derived( t0) ,m_events_queue() ,m_deferred_events_queue()
,m_history() ,m_event_processing(false) ,m_is_included(false)
,m_visitors() ,m_substate_list() { ::boost::mpl::for_each<
seq_initial_states, ::boost::msm::wrap<mpl::placeholders::_1> >
(init_states(m_states)); m_history.set_initial_states(m_states);
fill_states(this); }

In our case, if we want to pass a reference, ARG0 has to be declared as follows:
template < class ARG0>
state_machine<Derived,HistoryPolicy,CompilePolicy >( ARG0& t0 )
:Derived( t0) ....

The "Derived" class looks like as follows:
class "Derived"
{
public:
  Derived(SomeClass& cl_) {}
}

Do you have any idea how to solve this?

Thanks in advance.

Richie & Michi


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