diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/fatal_error.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/include/fatal_error.h b/include/fatal_error.h new file mode 100644 index 0000000..06e1b88 --- /dev/null +++ b/include/fatal_error.h @@ -0,0 +1,16 @@ +#ifndef FATAL_ERROR_H +#define FATAL_ERROR_H + +#include <format> +#include <cstdlib> +#include <cstdio> + +template <typename... Args> +[[noreturn]] void fatal_error(std::format_string<Args...> fmt, Args&&... args) { + std::string msg = std::format(fmt, std::forward<Args>(args)...); + std::fputs(msg.c_str(), stderr); + std::fputc('\n', stderr); + std::abort(); +} + +#endif |
