[ create a new paste ] login | about

Link: http://codepad.org/a98NzemO    [ raw code | fork ]

C++, pasted on Nov 30:
#include <exception>

struct A : std::exception {};
struct B : std::exception {};

void f() {}

bool caught_A_or_B()
{
    try { throw; }
    catch (A&) { return true; }
    catch (B&) { return true; }
    catch (...) { return false; }
}

int main()
{
    try
    {
        f();
        return 0;
    }
    catch (std::exception& e)
    {
        if (caught_A_or_B())
        {
            // ...
        }
        // ...
        return 1;
    }
}


Output:
No errors or program output.


Create a new paste based on this one


Comments: