
From: Emil Dotchevski via Boost Sent: Donnerstag, 13. Juli 2017 20:12
Have you thought about using a type-erased factory - like function
- as the error type? exception_ptr needs a memory allocation so that's a no-go.
Yes, exception_ptr needs a memory allocation. And atomic ref counting. Which is why I wrote factory function. The idea is that most of the time, you don't want/need to inspect the error, you just have to know that it happened and maybe be able to pass it on. Which can be very efficient if you return a factory. I understand that this is far from perfect, but it's the best idea I have for a single type that can transport arbitrary error information. (An alternative would be a functor that throws the exception when called, but AFAIK that will be even slower - much slower.)