On 15/02/2022 15:11, Emil Dotchevski wrote:
In terms of the latter, Gavin quite literally describes Boost LEAF. It is indeed possible for "Boost-aware" throws to automatically detect what info is actually needed for error handling, and only spend cycles capturing that. This is exactly how leaf::on_error works.
Not quite. LEAF works explicitly through TLS rather than the local stack, which makes it less compatible with coroutines, AFAIK. Granted that the mechanism I proposed would probably not be implementable without a TLS root to register with or something; while the context objects themselves would naturally be coroutine-compatible, a way to actually *find* which ones are still in scope in a particular context is harder to manage without making those sorts of assumptions. Unfortunately C++ lacks execution-context-ambient state that would work in either scenario.