$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Klaus Nowikow (nowikow_at_[hidden])
Date: 2004-03-30 12:20:32
> From: Rene Rivera [mailto:grafik.list_at_[hidden]]
> Rob Stewart wrote:
> > From: Rene Rivera <grafik.list_at_[hidden]>
> > 
> >>Gennaro Prota wrote:
> >>
> >>>On Sat, 27 Mar 2004 19:23:50 -0500, David Abrahams
> >>><dave_at_[hidden]> wrote:
> >>>
> >>>>"Klaus Nowikow" <nowikow_at_[hidden]> writes:
> >>>>
> >>>>>Reece Dunn wrote:
> >>>>>[snip]
> >>>>>
> >>>>>
> >>>>>>  class errorcheck
> >>>>>>  {
> >>>>>
> >>>>>[snip]
> >>>>>
> >>>>>>     public:
> >>>>>>        inline errorcheck( int ec ): error( ec )
> >>>>>>        {
> >>>>>>           if( ec < 0 ) throw( *this );
> >>>>>>        }
> >>>>>
> >>>>>Careful. Throwing an exception from a constructor
> >>>>>means that the object won't be constructed (i. e., does 
> not exist).
> >>>>>So you are throwing a non-existing object here.
> >>>>>
> >>>>>Or am I wrong?
> >>>>
> >>>>You're wrong.  *this is copied before it is thrown.  
> Still, the idiom
> >>>>above seems a bit suspicious, unless you somehow prevent 
> derivation
> >>>
> >>>>from errorcheck.
> >>>
> >>>I can't believe you are justifying the above. You copy an 
> object that
> >>>doesn't exist yet! (The class is not a POD and has a non trivial
> >>>constructor - and even if this wasn't the case...)
> >>
> >>I don't see how the object is not fully initialized inside 
> its constructor?? 
> >>Could you explain your objection?
> > 
> > 
> > Until the ctor finishes -- after the closing } -- there is no
> > object (see 3.8/1).
> 
> Yes the object lifetime hasn't started... but the object is 
> initialized. Which 
> according to 12.7 allows for referring to members of the 
> object directly or 
> indirectly, in this case by a copy ctor function.
I think you are right. When I posted the message above, I didn't take
into consideration that the object (*this) is copied before it is thrown.
Best regards,
Klaus