libassert
libassert copied to clipboard
Unconditional assertion that does not cause [[noreturn]]
Hi and thanks for the amazing library!
For handling unexpected values, I would like an unconditional assertion for which a custom assertion handler can decide not to abort, i.e. one that is not annotated with [[noreturn]]
. Something like:
enum_value ToEnum(std::uint8_t byte)
{
switch (value) {
case 0x00: return enum_value::first;
case 0x01: return enum_value::second;
}
UNEXPECTED(byte); // Like PANIC(byte) but can continue if the assertion handler does not abort
return enum_value::unexpected;
}
I want to be able to crash in debug (to make it obvious during testing) but in release, report the value via the assertion handler and continue (to avoid crashing the app for users).
If this is something you'll be interested in as well, I can open a PR for that.