Boost logo

Boost :

From: Rene Rivera (grafik.list_at_[hidden])
Date: 2004-03-28 11:41:11


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]
>>>
>>>>A trick I use when handling HRESULT error codes is to have a
>>>>class like this
>>>>(adapted for int error type):
>>>>
>>>> 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?

-- 
-- Grafik - Don't Assume Anything
-- Redshift Software, Inc. - http://redshift-software.com
-- rrivera/acm.org - grafik/redshift-software.com - 102708583/icq

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk