#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;
}
}