boost::fsm and templated states
Hi, I'm trying to get templated states to work with boost::fsm. Background is that I want to create an OptionsDialog I can show from different screens. So for now this works: template<class ParentState> class OptionsDialog : public boost::fsm::simple_state< OptionsDialog<ParentState>, ParentState, boost::mpl::list< boost::fsm::transition<EvOptionsExit, ParentState>, boost::fsm::custom_reaction<EvOptionsSound>, boost::fsm::custom_reaction<EvOptionsSoundExit> > > { //... }; This works perfectly so far. Now, what I want to do is have inside of the OptionsDialog substates (one for the sound-panel, one for video, etc.). This is my attempt so far: template <class Parent> class InnerInitial; template<class ParentState> class OptionsDialog : public boost::fsm::simple_state< OptionsDialog<ParentState>, ParentState, boost::mpl::list< boost::fsm::transition<EvOptionsExit, ParentState>, boost::fsm::custom_reaction<EvOptionsSound>, boost::fsm::custom_reaction<EvOptionsSoundExit> > >, InnerInitial< OptionsDialog<ParentState> { //... }; template <class Parent> class InnerInitial : public fsm::simple_state<InnerInitial<Parent>, Parent> { }; When trying to compile this (and of course using the OptionsDialog as a substate somewhere) I get the following compiler errors (sorry, I know it's long, but I couldn't make any sense of it so I don't know whats important). Could anyone shed some light on this? Thanks a lot, Jan Eickmann f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(191) : error C2039: 'inner_context_type' : is not a member of 'Xenocide::Client::UI::Common::OptionsDialog<ParentState>' with [ ParentState=Xenocide::Client::UI::Geoscape::PlanetviewState ] f:\xenocide\xenocide\src\client\ui\optionsdialog\optionsdialog.h(175) : see reference to class template instantiation 'boost::fsm::simple_state<MostDerived,Context>' being compiled with [ MostDerived=Xenocide::Client::UI::Common::InnerInitial<Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>>, Context=Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState> ] f:\xenocide\devpack.net2003\dependencies\include\boost\mpl\aux_\has_tag.hpp(20) : see reference to class template instantiation 'Xenocide::Client::UI::Common::InnerInitial<Parent>' being compiled with [ Parent=Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState> ] f:\xenocide\devpack.net2003\dependencies\include\boost\mpl\sequence_tag.hpp(112) : see reference to class template instantiation 'boost::mpl::aux::has_tag<T>' being compiled with [ T=Xenocide::Client::UI::Common::InnerInitial<Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>> ] f:\xenocide\devpack.net2003\dependencies\include\boost\mpl\begin_end.hpp(33) : see reference to class template instantiation 'boost::mpl::sequence_tag<Sequence>' being compiled with [ Sequence=Xenocide::Client::UI::Common::InnerInitial<Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>> ] f:\xenocide\devpack.net2003\dependencies\include\boost\mpl\is_sequence.hpp(94) : see reference to class template instantiation 'boost::mpl::begin<Sequence>' being compiled with [ Sequence=Xenocide::Client::UI::Common::InnerInitial<Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>> ] f:\xenocide\devpack.net2003\dependencies\include\boost\mpl\if.hpp(63) : see reference to class template instantiation 'boost::mpl::is_sequence<T>' being compiled with [ T=Xenocide::Client::UI::Common::InnerInitial<Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>> ] f:\xenocide\devpack.net2003\dependencies\include\boost\mpl\eval_if.hpp(40) : see reference to class template instantiation 'boost::mpl::if_<T1,T2,T3>' being compiled with [ T1=boost::mpl::is_sequence<Xenocide::Client::UI::Common::InnerInitial<Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>>>, T2=boost::mpl::identity<Xenocide::Client::UI::Common::InnerInitial<Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>>>, T3=boost::mpl::identity<boost::mpl::list<Xenocide::Client::UI::Common::InnerInitial<Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>>>> ] f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(71) : see reference to class template instantiation 'boost::mpl::eval_if<C,F1,F2>' being compiled with [ C=boost::mpl::is_sequence<Xenocide::Client::UI::Common::InnerInitial<Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>>>, F1=boost::mpl::identity<Xenocide::Client::UI::Common::InnerInitial<Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>>>, F2=boost::mpl::identity<boost::mpl::list<Xenocide::Client::UI::Common::InnerInitial<Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>>>> ] f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(82) : see reference to class template instantiation 'boost::fsm::detail::make_list<T>' being compiled with [ T=Xenocide::Client::UI::Common::InnerInitial<Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>> ] f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(191) : see reference to class template instantiation 'boost::fsm::detail::simple_state_base_type<MostDerived,Context,InnerInitial>' being compiled with [ MostDerived=Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>, Context=boost::fsm::simple_state<Xenocide::Client::UI::Geoscape::PlanetviewState,Xenocide::Client::UI::RunningGameState,boost::mpl::list<boost::fsm::custom_reaction<Xenocide::Client::UI::Geoscape::EvXNet>,boost::fsm::custom_reaction<Xenocide::Client::UI::Geoscape::EvOptions>,boost::fsm::custom_reaction<Xenocide::Client::UI::Common::EvOptionsAbandonGame>>,Xenocide::Client::UI::Geoscape::PlanetviewNoOpInnerInitial,has_no_history>::inner_context_type, InnerInitial=Xenocide::Client::UI::Common::InnerInitial<Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>> ] f:\xenocide\xenocide\src\client\ui\optionsdialog\optionsdialog.h(57) : see reference to class template instantiation 'boost::fsm::simple_state<MostDerived,Context,Reactions,InnerInitial>' being compiled with [ MostDerived=Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>, Context=Xenocide::Client::UI::Geoscape::PlanetviewState, Reactions=boost::mpl::list<boost::fsm::transition<Xenocide::Client::UI::Common::EvOptionsExit,Xenocide::Client::UI::Geoscape::PlanetviewState>,boost::fsm::custom_reaction<Xenocide::Client::UI::Common::EvOptionsSound>,boost::fsm::custom_reaction<Xenocide::Client::UI::Common::EvOptionsSoundExit>>, InnerInitial=Xenocide::Client::UI::Common::InnerInitial<Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>> ] f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(693) : see reference to class template instantiation 'Xenocide::Client::UI::Common::OptionsDialog<ParentState>' being compiled with [ ParentState=Xenocide::Client::UI::Geoscape::PlanetviewState ] f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(303) : see reference to function template instantiation 'boost::fsm::result boost::fsm::simple_state<MostDerived,Context,Reactions,InnerInitial,historyMode>::transit_impl<DestinationState,MostDerived,boost::fsm::detail::no_transition_function>(const TransitionAction &)' being compiled with [ MostDerived=Xenocide::Client::UI::Geoscape::PlanetviewState, Context=Xenocide::Client::UI::RunningGameState, Reactions=boost::mpl::list<boost::fsm::custom_reaction<Xenocide::Client::UI::Geoscape::EvXNet>,boost::fsm::custom_reaction<Xenocide::Client::UI::Geoscape::EvOptions>,boost::fsm::custom_reaction<Xenocide::Client::UI::Common::EvOptionsAbandonGame>>, InnerInitial=Xenocide::Client::UI::Geoscape::PlanetviewNoOpInnerInitial, historyMode=has_no_history, DestinationState=Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>, TransitionAction=boost::fsm::detail::no_transition_function ] f:\xenocide\xenocide\src\client\ui\planetview\planetview.cpp(371) : see reference to function template instantiation 'boost::fsm::result boost::fsm::simple_state<MostDerived,Context,Reactions,InnerInitial,historyMode>::transit<Xenocide::Client::UI::Common::OptionsDialog<ParentState>>(void)' being compiled with [ MostDerived=Xenocide::Client::UI::Geoscape::PlanetviewState, Context=Xenocide::Client::UI::RunningGameState, Reactions=boost::mpl::list<boost::fsm::custom_reaction<Xenocide::Client::UI::Geoscape::EvXNet>,boost::fsm::custom_reaction<Xenocide::Client::UI::Geoscape::EvOptions>,boost::fsm::custom_reaction<Xenocide::Client::UI::Common::EvOptionsAbandonGame>>, InnerInitial=Xenocide::Client::UI::Geoscape::PlanetviewNoOpInnerInitial, historyMode=has_no_history, ParentState=Xenocide::Client::UI::Geoscape::PlanetviewState ] f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(191) : error C2146: syntax error : missing ',' before identifier 'inner_context_type' f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(191) : error C2065: 'inner_context_type' : undeclared identifier f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(191) : error C2976: 'boost::fsm::detail::simple_state_base_type' : too few template arguments f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(99) : see declaration of 'boost::fsm::detail::simple_state_base_type' f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(191) : error C2955: 'boost::fsm::detail::simple_state_base_type' : use of class template requires template argument list f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(99) : see declaration of 'boost::fsm::detail::simple_state_base_type' f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(191) : error C2955: 'boost::fsm::detail::simple_state_base_type' : use of class template requires template argument list f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(99) : see declaration of 'boost::fsm::detail::simple_state_base_type' f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(192) : fatal error C1903: unable to recover from previous error(s); stopping compilation xnet.cpp
Mea culpa!!! I should really RTFM: <quote> If there is only a single inner initial state that is not a template instantiation then it can also be passed directly, without wrapping it into an mpl::list<>. </quote> Since mine is a template... Sorry for having bothering you, but I really cracked my head over this for several days... Jan Jan Eickmann wrote:
Hi,
I'm trying to get templated states to work with boost::fsm. Background is that I want to create an OptionsDialog I can show from different screens.
So for now this works: template<class ParentState> class OptionsDialog : public boost::fsm::simple_state< OptionsDialog<ParentState>, ParentState, boost::mpl::list< boost::fsm::transition<EvOptionsExit, ParentState>, boost::fsm::custom_reaction<EvOptionsSound>, boost::fsm::custom_reaction<EvOptionsSoundExit> > > { //... };
This works perfectly so far.
Now, what I want to do is have inside of the OptionsDialog substates (one for the sound-panel, one for video, etc.). This is my attempt so far:
template <class Parent> class InnerInitial;
template<class ParentState> class OptionsDialog : public boost::fsm::simple_state< OptionsDialog<ParentState>, ParentState, boost::mpl::list< boost::fsm::transition<EvOptionsExit, ParentState>, boost::fsm::custom_reaction<EvOptionsSound>, boost::fsm::custom_reaction<EvOptionsSoundExit> > >, InnerInitial< OptionsDialog<ParentState> { //... };
template <class Parent> class InnerInitial : public fsm::simple_state<InnerInitial<Parent>, Parent> {
};
When trying to compile this (and of course using the OptionsDialog as a substate somewhere) I get the following compiler errors (sorry, I know it's long, but I couldn't make any sense of it so I don't know whats important). Could anyone shed some light on this?
Thanks a lot,
Jan Eickmann
f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(191) : error C2039: 'inner_context_type' : is not a member of 'Xenocide::Client::UI::Common::OptionsDialog<ParentState>' with [ ParentState=Xenocide::Client::UI::Geoscape::PlanetviewState ]
f:\xenocide\xenocide\src\client\ui\optionsdialog\optionsdialog.h(175) : see reference to class template instantiation 'boost::fsm::simple_state<MostDerived,Context>' being compiled with [
MostDerived=Xenocide::Client::UI::Common::InnerInitial<Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>>,
Context=Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>
]
f:\xenocide\devpack.net2003\dependencies\include\boost\mpl\aux_\has_tag.hpp(20) : see reference to class template instantiation 'Xenocide::Client::UI::Common::InnerInitial<Parent>' being compiled with [
Parent=Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>
]
f:\xenocide\devpack.net2003\dependencies\include\boost\mpl\sequence_tag.hpp(112) : see reference to class template instantiation 'boost::mpl::aux::has_tag<T>' being compiled with [
T=Xenocide::Client::UI::Common::InnerInitial<Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>>
]
f:\xenocide\devpack.net2003\dependencies\include\boost\mpl\begin_end.hpp(33) : see reference to class template instantiation 'boost::mpl::sequence_tag<Sequence>' being compiled with [
Sequence=Xenocide::Client::UI::Common::InnerInitial<Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>>
]
f:\xenocide\devpack.net2003\dependencies\include\boost\mpl\is_sequence.hpp(94) : see reference to class template instantiation 'boost::mpl::begin<Sequence>' being compiled with [
Sequence=Xenocide::Client::UI::Common::InnerInitial<Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>>
]
f:\xenocide\devpack.net2003\dependencies\include\boost\mpl\if.hpp(63) : see reference to class template instantiation 'boost::mpl::is_sequence<T>' being compiled with [
T=Xenocide::Client::UI::Common::InnerInitial<Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>>
]
f:\xenocide\devpack.net2003\dependencies\include\boost\mpl\eval_if.hpp(40) : see reference to class template instantiation 'boost::mpl::if_<T1,T2,T3>' being compiled with [
T1=boost::mpl::is_sequence<Xenocide::Client::UI::Common::InnerInitial<Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>>>,
T2=boost::mpl::identity<Xenocide::Client::UI::Common::InnerInitial<Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>>>,
T3=boost::mpl::identity<boost::mpl::list<Xenocide::Client::UI::Common::InnerInitial<Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>>>>
]
f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(71) : see reference to class template instantiation 'boost::mpl::eval_if<C,F1,F2>' being compiled with [
C=boost::mpl::is_sequence<Xenocide::Client::UI::Common::InnerInitial<Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>>>,
F1=boost::mpl::identity<Xenocide::Client::UI::Common::InnerInitial<Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>>>,
F2=boost::mpl::identity<boost::mpl::list<Xenocide::Client::UI::Common::InnerInitial<Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>>>>
]
f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(82) : see reference to class template instantiation 'boost::fsm::detail::make_list<T>' being compiled with [
T=Xenocide::Client::UI::Common::InnerInitial<Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>>
]
f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(191) : see reference to class template instantiation 'boost::fsm::detail::simple_state_base_type<MostDerived,Context,InnerInitial>' being compiled with [
MostDerived=Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>,
Context=boost::fsm::simple_state<Xenocide::Client::UI::Geoscape::PlanetviewState,Xenocide::Client::UI::RunningGameState,boost::mpl::list<boost::fsm::custom_reaction<Xenocide::Client::UI::Geoscape::EvXNet>,boost::fsm::custom_reaction<Xenocide::Client::UI::Geoscape::EvOptions>,boost::fsm::custom_reaction<Xenocide::Client::UI::Common::EvOptionsAbandonGame>>,Xenocide::Client::UI::Geoscape::PlanetviewNoOpInnerInitial,has_no_history>::inner_context_type,
InnerInitial=Xenocide::Client::UI::Common::InnerInitial<Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>>
]
f:\xenocide\xenocide\src\client\ui\optionsdialog\optionsdialog.h(57) : see reference to class template instantiation 'boost::fsm::simple_state<MostDerived,Context,Reactions,InnerInitial>' being compiled with [
MostDerived=Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>,
Context=Xenocide::Client::UI::Geoscape::PlanetviewState,
Reactions=boost::mpl::list<boost::fsm::transition<Xenocide::Client::UI::Common::EvOptionsExit,Xenocide::Client::UI::Geoscape::PlanetviewState>,boost::fsm::custom_reaction<Xenocide::Client::UI::Common::EvOptionsSound>,boost::fsm::custom_reaction<Xenocide::Client::UI::Common::EvOptionsSoundExit>>,
InnerInitial=Xenocide::Client::UI::Common::InnerInitial<Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>>
]
f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(693) : see reference to class template instantiation 'Xenocide::Client::UI::Common::OptionsDialog<ParentState>' being compiled with [ ParentState=Xenocide::Client::UI::Geoscape::PlanetviewState ]
f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(303) : see reference to function template instantiation 'boost::fsm::result boost::fsm::simple_state<MostDerived,Context,Reactions,InnerInitial,historyMode>::transit_impl<DestinationState,MostDerived,boost::fsm::detail::no_transition_function>(const TransitionAction &)' being compiled with [ MostDerived=Xenocide::Client::UI::Geoscape::PlanetviewState, Context=Xenocide::Client::UI::RunningGameState,
Reactions=boost::mpl::list<boost::fsm::custom_reaction<Xenocide::Client::UI::Geoscape::EvXNet>,boost::fsm::custom_reaction<Xenocide::Client::UI::Geoscape::EvOptions>,boost::fsm::custom_reaction<Xenocide::Client::UI::Common::EvOptionsAbandonGame>>,
InnerInitial=Xenocide::Client::UI::Geoscape::PlanetviewNoOpInnerInitial, historyMode=has_no_history,
DestinationState=Xenocide::Client::UI::Common::OptionsDialog<Xenocide::Client::UI::Geoscape::PlanetviewState>,
TransitionAction=boost::fsm::detail::no_transition_function ]
f:\xenocide\xenocide\src\client\ui\planetview\planetview.cpp(371) : see reference to function template instantiation 'boost::fsm::result boost::fsm::simple_state<MostDerived,Context,Reactions,InnerInitial,historyMode>::transit<Xenocide::Client::UI::Common::OptionsDialog<ParentState>>(void)' being compiled with [ MostDerived=Xenocide::Client::UI::Geoscape::PlanetviewState, Context=Xenocide::Client::UI::RunningGameState,
Reactions=boost::mpl::list<boost::fsm::custom_reaction<Xenocide::Client::UI::Geoscape::EvXNet>,boost::fsm::custom_reaction<Xenocide::Client::UI::Geoscape::EvOptions>,boost::fsm::custom_reaction<Xenocide::Client::UI::Common::EvOptionsAbandonGame>>,
InnerInitial=Xenocide::Client::UI::Geoscape::PlanetviewNoOpInnerInitial, historyMode=has_no_history, ParentState=Xenocide::Client::UI::Geoscape::PlanetviewState ] f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(191) : error C2146: syntax error : missing ',' before identifier 'inner_context_type' f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(191) : error C2065: 'inner_context_type' : undeclared identifier f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(191) : error C2976: 'boost::fsm::detail::simple_state_base_type' : too few template arguments
f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(99) : see declaration of 'boost::fsm::detail::simple_state_base_type' f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(191) : error C2955: 'boost::fsm::detail::simple_state_base_type' : use of class template requires template argument list
f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(99) : see declaration of 'boost::fsm::detail::simple_state_base_type' f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(191) : error C2955: 'boost::fsm::detail::simple_state_base_type' : use of class template requires template argument list
f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(99) : see declaration of 'boost::fsm::detail::simple_state_base_type' f:\xenocide\devpack.net2003\dependencies\include\boost\fsm\simple_state.hpp(192) : fatal error C1903: unable to recover from previous error(s); stopping compilation xnet.cpp
Jan Eickmann wrote:
Mea culpa!!!
I should really RTFM:
<quote> If there is only a single inner initial state that is not a template instantiation then it can also be passed directly, without wrapping it into an mpl::list<>. </quote>
Since mine is a template...
Sorry for having bothering you,
No need to apologize ...
but I really cracked my head over this for several days...
:-o several days? Please do ask earlier next time! BTW, there's another pitfall waiting for you with templated states, namely when you want to use fsm::state<> instead of fsm::simple_state<>. Please let me know right away when you hit that one! Regards, -- Andreas Huber When replying by private email, please remove the words spam and trap from the address shown in the header.
Andreas Huber wrote:
Jan Eickmann wrote:
Mea culpa!!!
I should really RTFM:
<quote> If there is only a single inner initial state that is not a template instantiation then it can also be passed directly, without wrapping it into an mpl::list<>. </quote>
Since mine is a template...
Sorry for having bothering you,
No need to apologize ...
but I really cracked my head over this for several days...
:-o several days? Please do ask earlier next time!
I'll do next time.
BTW, there's another pitfall waiting for you with templated states, namely when you want to use fsm::state<> instead of fsm::simple_state<>. Please let me know right away when you hit that one!
Regards,
I will, thanks for the "obscure" hint :-) Great lib, btw. Jan
Hi all, I would like to know if there is a way right now or if there is a plan to add the possibility of using bll::bind (boost lambda bind) with shared_ptr as one uses it with normal pointers. This functionality is currently supported by boost::bind but I cannot find a way to make it work with lambda bind. For example: class CFoo { public: void SetI(const int & nI) { ... } }; std::vector<CFoo*> vpFoos; std::vector< boost::shared_ptr<CFoo> > vpFoos2; //Assume I initialize the vectors std::for_each(vpFoos.begin(),vpFoos.end(), boost::lambda::bind(&CFoo::SetI, boost::lambda::_1, 5)); //Works great //I _cannot_ find to make this work with vpFoos2; I _can_ make it work with boost::bind. Thanks -delfin
Can somebody comment in this, please? Thanks -delfin
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Delfin Rojas Sent: Wednesday, February 16, 2005 7:09 PM To: boost-users@lists.boost.org Subject: [Boost-users] Boost lambda and shared_ptr
Hi all,
I would like to know if there is a way right now or if there is a plan to add the possibility of using bll::bind (boost lambda bind) with shared_ptr as one uses it with normal pointers.
This functionality is currently supported by boost::bind but I cannot find a way to make it work with lambda bind.
For example:
class CFoo { public: void SetI(const int & nI) { ... } };
std::vector<CFoo*> vpFoos; std::vector< boost::shared_ptr<CFoo> > vpFoos2;
//Assume I initialize the vectors
std::for_each(vpFoos.begin(),vpFoos.end(), boost::lambda::bind(&CFoo::SetI, boost::lambda::_1, 5)); //Works great
//I _cannot_ find to make this work with vpFoos2; I _can_ make it work with boost::bind.
Thanks
-delfin
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
I guess I had not done my homework all the way. I found a way to make bll::bind work when the placeholder is a shared_ptr by dereferencing it. In other words, std::for_each(vpFoos2.begin(),vpFoos2.end(), boost::lambda::bind(&CFoo::SetI, *boost::lambda::_1, 5)); While this solves most of my problems I still cannot make it work for this other case: shared_ptr<CFoo> pFoo(new CFoo); std::vector<int> vnValues(10, 1); std::for_each(vnValues.begin(), vnValues.end(), boost::lambda::bind(&CFoo::SetI, pFoo, boost::lambda::_1)); I tried dereferencing pFoo but it didn't work. Anyone? Thanks -delfin
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Delfin Rojas Sent: Friday, February 18, 2005 11:09 AM To: boost-users@lists.boost.org Subject: RE: [Boost-users] Boost lambda and shared_ptr
Can somebody comment in this, please?
Thanks
-delfin
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Delfin Rojas Sent: Wednesday, February 16, 2005 7:09 PM To: boost-users@lists.boost.org Subject: [Boost-users] Boost lambda and shared_ptr
Hi all,
I would like to know if there is a way right now or if there is a plan to add the possibility of using bll::bind (boost lambda bind) with shared_ptr as one uses it with normal pointers.
This functionality is currently supported by boost::bind but I cannot find a way to make it work with lambda bind.
For example:
class CFoo { public: void SetI(const int & nI) { ... } };
std::vector<CFoo*> vpFoos; std::vector< boost::shared_ptr<CFoo> > vpFoos2;
//Assume I initialize the vectors
std::for_each(vpFoos.begin(),vpFoos.end(), boost::lambda::bind(&CFoo::SetI, boost::lambda::_1, 5)); //Works great
//I _cannot_ find to make this work with vpFoos2; I _can_ make it work with boost::bind.
Thanks
-delfin
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Delfin Rojas wrote:
I guess I had not done my homework all the way. I found a way to make bll::bind work when the placeholder is a shared_ptr by dereferencing it. In other words,
std::for_each(vpFoos2.begin(),vpFoos2.end(), boost::lambda::bind(&CFoo::SetI, *boost::lambda::_1, 5));
While this solves most of my problems I still cannot make it work for this other case:
shared_ptr<CFoo> pFoo(new CFoo); std::vector<int> vnValues(10, 1); std::for_each(vnValues.begin(), vnValues.end(), boost::lambda::bind(&CFoo::SetI, pFoo, boost::lambda::_1));
I tried dereferencing pFoo but it didn't work.
pFoo.get() should work. ref(*pFoo) or var(*pFoo) might also work.
Delfin Rojas wrote: [snip]
Anyone?
You might have more luck if you post this in a thread of its own. Regards, Andreas -- Andreas Huber When replying by private email, please remove the words spam and trap from the address shown in the header.
Delfin Rojas wrote:
While this solves most of my problems I still cannot make it work for this other case:
shared_ptr<CFoo> pFoo(new CFoo); std::vector<int> vnValues(10, 1); std::for_each(vnValues.begin(), vnValues.end(), boost::lambda::bind(&CFoo::SetI, pFoo, boost::lambda::_1));
I tried dereferencing pFoo but it didn't work.
My guess is that CFoo::SetI is not a const member function. Because *pFoo is being passed by const reference, compilation fails. You can workaround this in one of the following ways: boost::lambda::bind(&CFoo::SetI, pFoo.get(), // returns a raw pointer boost::lambda::_1)); boost::lambda::bind(&CFoo::SetI, boost::ref(*pFoo), // wrap *pFoo so it is passed // by (non-const) reference boost::lambda::_1)); boost::lambda::bind(&CFoo::SetI, boost::lambda::var(*pFoo), // wrap *pFoo so it is passed // by (non-const) reference boost::lambda::_1)); HTH, Best regards, João Abecasis
participants (5)
-
Andreas Huber
-
Delfin Rojas
-
Jan Eickmann
-
Joao Abecasis
-
Peter Dimov