
30 Mar
2004
30 Mar
'04
5:47 p.m.
Gennaro Prota <gennaro_prota@yahoo.com> 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