C++ Logo


Advanced search

Subject: Re: [important] C++ Zero-Overhead exception proposal
From: Jason McKesson (jmckesson_at_[hidden])
Date: 2020-10-19 12:49:02

FYI: You need to reply to the list to keep the discussion on the list.

On Mon, Oct 19, 2020 at 3:49 AM Denis Kotov <redradist_at_[hidden]> wrote:
> >> Being a "raw integer" is what gives us "zero overhead" (also,
> `std::error` is not a "raw integer"; it's two pointers in size)
> "Zero-overhead abstraction - don't pay for what you don't use, what you use is as efficient as you can reasonably write by hand" from side of Herb Sutter https://youtu.be/ARYP83yNAWk?t=328
> You cannot write more efficiently than that:
> ```cppunion SubscribeResult { Subscription res; SubscriptionError err;
> };```
> Returning raw integer as error code is also "Zero-overhead", but it is applied for some specific case ...
> What if with error you want to return data for this error ?
> It will become very hard to extend such an error system ..

`std::error` as proposed by P0709 ***is not an integer***. It is a
specialized type that can store integer values, but it can also store
any data structure through an `exception_ptr`. Yes, they must be
dynamically-allocated, but returning large structs isn't exactly
"zero-overhead" either. This is especially true when throwing them.

The functionality you want can already be done with the existing
P0709, just not in quite as convenient a way.

STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups