Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-02-25 08:37:18


"Philippe A. Bouchard" <philippeb_at_[hidden]> writes:

> David Abrahams wrote:
>
> [...]
>
>>> What will happen to a normal type then?
>>
>> What is a "normal type"?
>
> Any type besides optional<T>.
>
>>> {
>>> T storage = T(x, y, z); // throws
>>>
>>> // storage.~T() destroys non-existent T
>>
>> Storage never gets constructed if T(x,y,z) throws, so it is also
>> never destroyed.
>
> It is never destroyed, because the program counter returns from the function
> before it reaches the object's destruction?

And more-importantly, before it reaches the object's construction.

> If so, the same will happen to aligned_storage<T>::type if it trows
> an exception?

Once again, the case was:

    {
        aligned_storage<T>::type storage;

        new ((void*)&storage) T(x, y, z); // throws

        // ~aligned_storage<T>() destroys non-existent T
    }

The question is not what happens if aligned_storage<T>::type throws.
It will never throw, since it is POD. The question is what happens
if T throws.

If, as you say, you don't know much about EH, please do a little bit
of research about how it works before you argue with me on this one
:-)

-- 
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