函式嘗試塊在解構函式中

struct A
{
    ~A() noexcept(false) try
    {
        // destructor body 
    }
    catch (...)
    {
        // exceptions of destructor body are caught here
        // if no exception is thrown here
        // then the caught exception is re-thrown.
    }
};

請注意,雖然這是可能的,但是從解構函式中丟擲需要非常小心,就像在堆疊展開期間呼叫的解構函式丟擲異常一樣,呼叫 std::terminate