hachyderm.io is one of the many independent Mastodon servers you can use to participate in the fediverse.
Hachyderm is a safe space, LGBTQIA+ and BLM, primarily comprised of tech industry professionals world wide. Note that many non-user account types have restrictions - please see our About page.

Administered by:

Server stats:

9.4K
active users

Šimon Tóth

When working with exceptions in C++, there are three main levels of guarantees a function can provide when an exception is thrown.

🧵👇

Compiler Explorer link: compiler-explorer.com/z/T9YKKa

𝑴𝒊𝒏𝒊𝒎𝒖𝒎 𝒈𝒖𝒂𝒓𝒂𝒏𝒕𝒆𝒆: 𝒏𝒐 𝒊𝒏𝒗𝒂𝒓𝒊𝒂𝒏𝒕𝒔 𝒂𝒓𝒆 𝒗𝒊𝒐𝒍𝒂𝒕𝒆𝒅, 𝒂𝒏𝒅 𝒏𝒐 𝒓𝒆𝒔𝒐𝒖𝒓𝒄𝒆𝒔 𝒂𝒓𝒆 𝒍𝒆𝒂𝒌𝒆𝒅.

This is the minimum level for the standard library. Any codebase that has exceptions enabled should maintain at least this level.

𝑺𝒕𝒓𝒐𝒏𝒈 𝒈𝒖𝒂𝒓𝒂𝒏𝒕𝒆𝒆: 𝒕𝒉𝒆 𝒔𝒕𝒂𝒕𝒆 𝒘𝒊𝒍𝒍 𝒏𝒐𝒕 𝒃𝒆 𝒄𝒉𝒂𝒏𝒈𝒆𝒅.

Operations are transactional; they either happen entirely without error or not at all.

While this is very nice to code against, strong exception guarantee support can be prohibitively expensive (or even impossible).

𝑵𝒐𝒕𝒉𝒓𝒐𝒘 𝒈𝒖𝒂𝒓𝒂𝒏𝒕𝒆𝒆: 𝒏𝒐 𝒆𝒙𝒄𝒆𝒑𝒕𝒊𝒐𝒏 𝒘𝒊𝒍𝒍 𝒃𝒆 𝒕𝒉𝒓𝒐𝒘𝒏.

Suitable for trivial operations and building blocks of more complex functions that need to provide strong guarantees.

Note that this property should be consistent across all build configurations.