Replace the Error() object with an error() function which takes fmt

formatspecs, making for much cleaner code. Reformatted everything.

This actually happened in multiple steps but then I corrupted my local
repository and I had to recover from the working tree.
This commit is contained in:
dg
2023-05-09 20:59:44 +00:00
parent bfa0846ad0
commit 466c3c34e5
168 changed files with 5722 additions and 5135 deletions

View File

@@ -15,6 +15,7 @@
#include <climits>
#include <variant>
#include <optional>
#include <fmt/format.h>
#if defined(_WIN32) || defined(__WIN32__)
#include <direct.h>
@@ -41,29 +42,12 @@ struct ErrorException
void print() const;
};
class Error
template <typename... Args>
[[ noreturn ]]
inline void error(fmt::string_view fstr, const Args&... args)
{
public:
Error()
{
_stream << "Error: ";
}
[[ noreturn ]] ~Error() noexcept(false)
{
throw ErrorException { _stream.str() };
}
template <typename T>
Error& operator<<(T&& t)
{
_stream << t;
return *this;
}
private:
std::stringstream _stream;
};
throw ErrorException { fmt::format(fstr, args...) };
}
template <class... Ts> struct overloaded : Ts... { using Ts::operator()...; };
template <class... Ts> overloaded(Ts...) -> overloaded<Ts...>;