Consider an exception class with a copy constructor with side effects.
Can the compiler skip calling the copy constructor here:
try { throw ugly_exception(); } catch(ugly_exception) // ignoring the exception, so I'm not naming it { }
How about this:
try { something_that_throws_ugly_exception(); } catch(ugly_exception) // ignoring the exception, so I'm not naming it { }
(yes, I know this is very ugly, it was inspired by another question )
c ++ optimization exception copy-elision
R. Martinho Fernandes
source share