diff options
Diffstat (limited to 'compat')
-rw-r--r-- | compat/failwith.hpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/compat/failwith.hpp b/compat/failwith.hpp new file mode 100644 index 00000000..580ed923 --- /dev/null +++ b/compat/failwith.hpp @@ -0,0 +1,21 @@ +#pragma once +#include "compat/assert.hpp" +#if !defined __GNUG__ && !defined _MSC_VER +#include <utility> +#endif + +namespace floormat { + +template<typename T> T failwith(const char* str) +{ + fm_abort("%s", str); +#ifdef __GNUG__ + __builtin_unreachable(); +#elif defined _MSC_VER + __assume(false); +#else + std::unreachable(); +#endif +} + +} // namespace floormat |