diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2024-02-14 22:28:18 +0100 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-02-14 22:30:48 +0100 |
| commit | cb2718ca0bc0ebdc1987dbb8851e4c3686a8ed7a (patch) | |
| tree | b5c6f2ffb0bdd95f88193b7c1fb695c9465ea33c | |
| parent | 64e6d6c051c9258a52737ec40c0e5d32adac270e (diff) | |
fix msvc warning
| -rw-r--r-- | compat/exception.cpp | 28 | ||||
| -rw-r--r-- | compat/exception.hpp | 4 | ||||
| -rw-r--r-- | src/exception.cpp | 7 |
3 files changed, 32 insertions, 7 deletions
diff --git a/compat/exception.cpp b/compat/exception.cpp new file mode 100644 index 00000000..f96578d7 --- /dev/null +++ b/compat/exception.cpp @@ -0,0 +1,28 @@ +#include "exception.hpp" + +namespace floormat { + +exception::exception(const exception& other) noexcept +{ + buf.reserve(other.buf.size()); + buf.append(other.buf.begin(), other.buf.end()); +} + +exception::exception(exception&& other) noexcept = default; + +exception& exception::operator=(const exception& other) noexcept +{ + if (&other != this) + { + buf.clear(); + buf.reserve(other.buf.size()); + buf.append(other.buf.begin(), other.buf.end()); + } + return *this; +} + +exception& exception::operator=(floormat::exception&&) noexcept = default; + +const char* exception::what() const noexcept { return buf.data(); } + +} // namespace floormat diff --git a/compat/exception.hpp b/compat/exception.hpp index eff75225..155547de 100644 --- a/compat/exception.hpp +++ b/compat/exception.hpp @@ -14,6 +14,10 @@ struct exception : std::exception, base_exception template<typename Fmt, typename... Ts> exception(const Fmt& fmt, Ts&&... args) noexcept; + exception(exception&&) noexcept; + exception(const exception& other) noexcept; + exception& operator=(exception&&) noexcept; + exception& operator=(const exception& other) noexcept; const char* what() const noexcept override; private: diff --git a/src/exception.cpp b/src/exception.cpp deleted file mode 100644 index 4855e240..00000000 --- a/src/exception.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "compat/exception.hpp" - -namespace floormat { - -const char* exception::what() const noexcept { return buf.data(); } - -} // namespace floormat |
