"Johan Nilsson" <johan.nilsson@[...].se> wrote in message
news:c96p5d$qlg$1@[...]..
> > "Andreas Huber" <ah2003@[...].net> wrote in message> news:loom.20040527T133057-890@[...]..> > Johan Nilsson <johan.nilsson <at> esrange.ssc.se> writes:> >> > > What's stopping me from always create them in constructor/delete in> > > destructor, then just init/deinit them (if necessary) in entry/exit?> >> > The fact that most classes (well-designed ones) don't have init/deinit.> >> > I'm totally aware of the RAII idom and didn't literally mean that the> classes had init/deinit methods which would> totally initialize and clean up the state. I referred to actions> (_manipulating_ already created members: classes/pods/built-ins) that> _might_ be necessary to call depending on the state in question.> > Ideally a state should be state-less, right? Once created it should always> be able to execute the same actions no matter when in time. IRL there's
more
> likely something that needs to be done to initiate the state. Does it
matter
> if this is a two-step procedure:> > Allocate in constructors + Initialize in entry> > or one-step:> > Allocate and initialize in constructor.
class astate : non_copyable
{
T& mRef;
astate();
public:
astate( T& aRef ):mRef(aRef){ aRef.somefunction(); }
void init( T& aRef ){ mRef = aRef; mRef.somefunction(); } // not the
same
};
Jeff Flinn
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost