I keep seeing the assertion that C++ exceptions create performance problems but I am yet to see actual data to support it. Not a simple toy case but an actual program that was shown to be slow when using exceptions, that issue couldn't be fixed otherwise and the solution was to not use exceptions.
As I already said, throwing and catching C++ exceptions on a table based EH implementation is very slow, and moreover, unpredictably so. It costs approx 1500-3000 CPU cycles per stack frame unwound. In this situation, using integer error codes, or error_code, or Outcome instead delivers huge improvements.
Practically speaking exception handling overhead occurs only at function entry and exit.
Only the case on non-table based EH implementations such as MSVC x86. Anything newer has zero, absolutely *zero* runtime overhead except for code bloat effect on cache exhaustion.
It disappears in thin air (all of it) by simply inlining the function, which would be done in performance-critical parts of the code anyway (and MSVC, whose exception handling overhead is probably the worst, can inline functions even at link time.)
Actually MSVC's exception handling performance with table based EH is by far the best of any of the major compilers. It's twice as fast as GCC for example. The next best is Apple XCode, and far behind is POSIX clang and GCC.
So I must ask: what is the practical problem solved by not using exceptions in general and Outcome in particular? It seems to me this is driven by a design preference for one coding style over another, which is fine, but nobody seems to be having that discussion. The cost of not using exceptions is that we're throwing away the ability to enforce postconditions. What's the upside?
If you are using integer return codes, the claim is that you should be using Expected/Outcome instead for much improved almost everything. My ACCU talk video covers this in depth. Niall -- ned Productions Limited Consulting http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/