7 ms·
Don't write constructors that can fail unless it is failure that would be appropriate to crash for. That works out a lot better than it might naively sound. It
by _b 5y ago
Don't write constructors that can fail unless it is failure that would be appropriate to crash for. That works out a lot better than it might naively sound. It is hard for people to reason about the possibility of constructors/destructors failing, so actually rather nice to just forbid it.
- addaon 5y agoAnd for those super-rare cases where it's appropriate to crash / fail hard in a constructor but you still have requirements about reporting or even recovery... setjmp/longjmp still exist.
- ncmncm 5y agoYou have always had the choice available to do something overwhelmingly worse than throwing. That is not a reason to do it.
- throwaway5486nv 5y ago