Better HN
topnewbestaskshowjobs
Log inSign up

safety-second

2 karma · joined Feb 3, 2020 (6y ago) · 2 submissions

Submissions

comment 6y ago · link · parent

You could use a File class that throws on EOF, but that would be a really bad idea for C++ since throw/catch are very expensive.

comment 6y ago · link · parent

C++ exceptions are only good if you use them like signals from C or panics in Go. This means you have to use error values for 99% of errors or you lose this benefit. The fact that the STL sprinkles exceptions everywhere doesn't help this. C++ exceptions are so non-deterministic and slow that every real-time system disables them just to be sure.