martinmoene / expected-dark

Expected objects for C++11 and later (and later perhaps C++98 )
MIT License
52 stars 4 forks source link

What's the cost of expected-lite vs an exception? #2

Closed ruipacheco closed 7 years ago

ruipacheco commented 7 years ago

Is expected-lite much more expensive than using exceptions? It's very practical and would lead to significantly cleaner code than exception handling but what is the runtime cost?

ruipacheco commented 7 years ago

Bump

martinmoene commented 7 years ago

I have not investigated it. The answer likely is: it depends -- on the specifics of how/where you use it.

Would be nice if you could shed some light on it !

martinmoene commented 7 years ago

@ruipacheco At the ACCU 2017 Conference, Niall Douglas did a talk on std::expected:

Mongrel Monads, Dirty, Dirty, Dirty - Niall Douglas [ACCU 2017]

57 minutes in is a section Benchmarking performance; Why not just throw exception and save all this hassle?

Tutorial text and code as in video (Github repo for Boost.Outcome).

ruipacheco commented 7 years ago

Will check it asap.