From: Reece Dunn (msclrhd_at_[hidden])
Date: 2004-03-30 14:06:00
>From: Rob Stewart <stewart_at_[hidden]>
>From: "Reece Dunn" <msclrhd_at_[hidden]>
> > So the errorcheck object will be in a half-constructed state. That is,
> > int will be constructed, but the errorcheck object isn't, therefore the
> > int's destructor will be called, but errorcheck's deconstructor will
> > The solution would therefore be to throw an intermediate object, like
> > Trules from the C++ Templates book by David Vandervoorde and Nico
> > This would then get around the throwing in a constructor problem.
>Why not throw a new errorcheck object using a private ctor that
>stores but doesn't check the return value?
That would work (I realised an implementation after the post). But this is
what I was trying to achieve using the copy constructor (and copy
assignment), since that copies the object, but does not throw on failure.
The errorcheck class now has a policy-based implementation, so it would look
template< typename ErrorStorage, typename ErrorMsgStorage >
class errorcheck: public Storage, public MsgStorage
inline errorcheck( const Storage & s, const MsgStorage & ms ):
Storage( s ), MsgStorage( ms )
inline errorcheck( typename Storage::error_type e ):
Storage( e ), MsgStorage()
throw( errorcheck< Storage, MsgStorage >( *this, *this ));
which, IMHO, is more confusing than the straight throw( *this ), but does
not use the copy constructor, relying instead of the fully constructed
Storage and MsgStorage base classes.
Find a cheaper internet access deal - choose one to suit you.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk