   #include <iostream>
    #include <memory>

    struct Foo {
        int x_;
        Foo (int const x): x_(x) {
            if (x == 1) {
            throw x;
            }
        }
        ~Foo() { std::cerr << "foo_" << x_ << " destroyed" << std::endl; }
    };

    struct Bar {
        std::shared_ptr<Foo> foo_0;
        std::shared_ptr<Foo> foo_1;
        std::shared_ptr<Foo> foo_2;
        Bar(): 
            foo_0 (std::make_shared<Foo>(0)),
            foo_1 (std::make_shared<Foo>(1)),
            foo_2 (std::make_shared<Foo>(2)) {
        }
        ~Bar() {
            std::cerr << "Bar destroyed" << std::endl;
        }
    };

    void xul() {
        Bar bar;
    }

    int main() {
        try { xul(); } catch (...) { return EXIT_FAILURE; }
    }