Boost logo

Boost :

From: Jeff Flinn (TriumphSprint2000_at_[hidden])
Date: 2004-05-28 07:14:35

"Johan Nilsson" <johan.nilsson_at_[hidden]> wrote in message
> "Andreas Huber" <ah2003_at_[hidden]> wrote in message
> > Johan Nilsson <johan.nilsson <at>> 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
> likely something that needs to be done to initiate the state. Does it
> 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( T& aRef ):mRef(aRef){ aRef.somefunction(); }

    void init( T& aRef ){ mRef = aRef; mRef.somefunction(); } // not the


Jeff Flinn

Boost list run by bdawes at, gregod at, cpdaniel at, john at