nothrow by default

Johannes Pfau nospam at example.com
Sun Jan 5 21:12:39 UTC 2020


Am Sun, 05 Jan 2020 21:06:00 +0000 schrieb Johannes Pfau:

> Am Sun, 05 Jan 2020 19:53:59 +0000 schrieb Ola Fosheim Grøstad:
> 
>> On Sunday, 5 January 2020 at 15:02:59 UTC, Johannes Pfau wrote:
>>> This certainly needs to be considered, however: Some languages such as
>>> go (server!) and C++ with std:error decided to go for error codes for
>>> error handling.
>> 
>> What is "std::error"? If you mean "std::error_code" then it is for
>> wrapping OS error codes like the ones from Unix. (You can throw it if
>> want...)
>> 
>> 
> As far as I know, starting from C++11 std::error_code can be extended
> and has been used in newer updates to the C++ standard library instead
> of exceptions. (e.g. there is now a future error category). See https://
> akrzemi1.wordpress.com/2017/07/12/your-own-error-code/

Though looking at this, it seems they often throw exceptions containing 
these error codes? However, Herb Sutter explicitly mentioned 
std::error_code as causing fragmentation in C++ (e.g. std::filesystem 
uses both exceptions and error_code), see slide at https://youtu.be/
os7cqJ5qlzo?t=764

So I assumed error codes are common in modern C++, but I don't really 
have first-hand experience to say for sure.


-- 
Johannes


More information about the Digitalmars-d mailing list