summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--compat/exception.cpp28
-rw-r--r--compat/exception.hpp4
-rw-r--r--src/exception.cpp7
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