summaryrefslogtreecommitdiff
path: root/include/fatal_error.h
blob: 06e1b8848bb03bdc3ee13f9d12268116552806d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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