summaryrefslogtreecommitdiffstats
path: root/src/libutil/cxx
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2022-10-18 23:09:55 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2022-10-18 23:09:55 +0100
commit5335bce593200298976fcd4992dcb14f86f291ed (patch)
treeebc5b809c1743472c6b183702df45951775846b7 /src/libutil/cxx
parentff8d45abef65ae9552a5c089317f96208474bbe6 (diff)
downloadrspamd-5335bce593200298976fcd4992dcb14f86f291ed.tar.gz
rspamd-5335bce593200298976fcd4992dcb14f86f291ed.zip
[Minor] Fix error copying/move behaviour
Diffstat (limited to 'src/libutil/cxx')
-rw-r--r--src/libutil/cxx/error.hxx28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/libutil/cxx/error.hxx b/src/libutil/cxx/error.hxx
index 65fa76f3b..714ed309b 100644
--- a/src/libutil/cxx/error.hxx
+++ b/src/libutil/cxx/error.hxx
@@ -69,6 +69,34 @@ public:
error_message = static_storage.value();
}
+ error(const error &other) : error_code(other.error_code), category(other.category) {
+ if (other.static_storage) {
+ static_storage = other.static_storage;
+ error_message = static_storage.value();
+ }
+ else {
+ error_message = other.error_message;
+ }
+ }
+
+ error(error &&other) noexcept {
+ *this = std::move(other);
+ }
+
+ error& operator = (error &&other) noexcept {
+ if (other.static_storage.has_value()) {
+ std::swap(static_storage, other.static_storage);
+ error_message = static_storage.value();
+ }
+ else {
+ std::swap(error_message, other.error_message);
+ }
+ std::swap(other.error_code, error_code);
+ std::swap(other.category, category);
+
+ return *this;
+ }
+
/**
* Convert into GError
* @return