|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2004-03-30 12:47:23
Gennaro Prota <gennaro_prota_at_[hidden]> writes:
>>> 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.
I'm not justifying it. I'm simply disagreeing with "you're throwing
a non-existing object here". OK, construction has not yet completed,
so it's a dubious practice, but the object surely exists at the point
of the throw.
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk