cpp_weekly icon indicating copy to clipboard operation
cpp_weekly copied to clipboard

Exceptions for better performance

Open lefticus opened this issue 3 years ago • 3 comments

A comparison of the monadic call chain interface from std::optional in C++23 and using exceptions to handle error cases instead.

lefticus avatar Sep 24 '22 15:09 lefticus

I would upvote this 10x if I could. I have long theorized, but never had the chance/taken the time to prove, that using exceptions to report uncommon conditions can be measurably faster than manually checking and propagating error return values, especially with a deep-ish call stack.

usefulcat avatar Apr 28 '23 01:04 usefulcat

could you add std::expected to the comparison?

fcolecumberri avatar Apr 29 '23 11:04 fcolecumberri

could you add std::expected to the comparison?

Good idea. I've observed that it's shockingly easy to use std::expected inefficiently.

cough implicit conversions cough

lefticus avatar Apr 29 '23 22:04 lefticus