Re:Measuring execution performance of C++ exceptions vs. err...
by pixel_fcker on Monday January 09, 2017 @02:42PM
(#13359148)
There's this: https://github.com/ptal/expected which seems to work pretty well in my tests so far, though I haven't benchmarked it yet. The default implementation uses exceptions as the error type but you can supply your own type (e.g. an int, string, or a wrapped version of either or both) trivially.
[ Parent
| on HN ]
Re:Measuring execution performance of C++ exceptions vs. err...
by je42 on Monday January 09, 2017 @02:57PM
(#13359279)
just looked at this, nice! but i wasn't able to find how in the document how to propagate errors up the stack ?
i.e. a parent function needs to expose an error type that is a base class of all errors that can occur the methods being called, right ?
and i wondering how you would get stack traces from these errors ?
Re:Measuring execution performance of C++ exceptions vs. err...
by pixel_fcker on Wednesday January 11, 2017 @02:34PM
(#13376768)
Best just to use std::exception as the base class and derive from that, then if you want to get a stack trace just rethrow the contained exception.
I've tried using this and my own implementation of Result<T,E> based on Alexandrescu's original talk, and both are significantly slower that C error codes or exceptions using the test program in the OP.