When is a function try block useful?

You use it in constructors to catch errors from initializers. Usually, you don’t catch those errors, so this is a quite exceptional use.

Otherwise, it is useless: unless I’m proven wrong,

void f() try { ... } catch (...) { ... }

is strictly equivalent to

void f() { try { ... } catch (...) { ... } }

Leave a Comment