2023-11-24 18:21:49 +01:00
|
|
|
#include <exception>
|
|
|
|
#include <format>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
class _todo : public std::exception {
|
|
|
|
std::string cause;
|
|
|
|
|
|
|
|
public:
|
|
|
|
_todo() : cause("not yet implemented") {}
|
|
|
|
_todo(std::string&& excuse) : cause("not yet implemented: " + excuse) {}
|
|
|
|
virtual const char* what() const throw() { return cause.c_str(); }
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Indicates unfinished code.
|
|
|
|
*/
|
2024-01-06 21:12:33 +01:00
|
|
|
[[noreturn]] void todo() { throw _todo(); }
|
2023-11-24 18:21:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Indicates unfinished code.
|
|
|
|
* @param fmt an object that represents the format string
|
|
|
|
* @param args arguments to be formatted
|
|
|
|
*/
|
|
|
|
template <class... Args>
|
2024-01-06 21:12:33 +01:00
|
|
|
[[noreturn]] void todo(std::format_string<Args...> fmt, Args&&... args) {
|
2023-11-24 18:21:49 +01:00
|
|
|
throw _todo(std::format(fmt, args...));
|
|
|
|
}
|
|
|
|
|
|
|
|
class _unimplemented : public std::exception {
|
|
|
|
std::string cause;
|
|
|
|
|
|
|
|
public:
|
|
|
|
_unimplemented() : cause("not implemented") {}
|
|
|
|
_unimplemented(std::string&& excuse)
|
|
|
|
: cause("not implemented: " + excuse) {}
|
|
|
|
virtual const char* what() const throw() { return cause.c_str(); }
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Indicates unimplemented code by throwing with a message of “not implemented”.
|
|
|
|
*/
|
2024-01-06 21:12:33 +01:00
|
|
|
[[noreturn]] void unimplemented() { throw _unimplemented(); }
|
2023-11-24 18:21:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Indicates unimplemented code by throwing with a message of “not implemented”.
|
|
|
|
* @param fmt an object that represents the format string
|
|
|
|
* @param args arguments to be formatted
|
|
|
|
*/
|
|
|
|
template <class... Args>
|
2024-01-06 21:12:33 +01:00
|
|
|
[[noreturn]] void unimplemented(std::format_string<Args...> fmt, Args&&... args) {
|
2023-11-24 18:21:49 +01:00
|
|
|
throw _unimplemented(std::format(fmt, args...));
|
|
|
|
}
|
|
|
|
|
|
|
|
class _unreachable : public std::exception {
|
|
|
|
std::string cause;
|
|
|
|
|
|
|
|
public:
|
|
|
|
_unreachable() : cause("entered unreachable code") {}
|
|
|
|
_unreachable(std::string&& excuse)
|
|
|
|
: cause("entered unreachable code: " + excuse) {}
|
|
|
|
virtual const char* what() const throw() { return cause.c_str(); }
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Indicates unreachable code.
|
|
|
|
*/
|
2024-01-06 21:12:33 +01:00
|
|
|
[[noreturn]] void unreachable() { throw _unreachable(); }
|
2023-11-24 18:21:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Indicates unreachable code.
|
|
|
|
* @param fmt an object that represents the format string
|
|
|
|
* @param args arguments to be formatted
|
|
|
|
*/
|
|
|
|
template <class... Args>
|
2024-01-06 21:12:33 +01:00
|
|
|
[[noreturn]] void unreachable(std::format_string<Args...> fmt, Args&&... args) {
|
2023-11-24 18:21:49 +01:00
|
|
|
throw _unreachable(std::format(fmt, args...));
|
|
|
|
}
|