aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/util/Private.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe/util/Private.cpp')
-rw-r--r--src/crepe/util/Private.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/crepe/util/Private.cpp b/src/crepe/util/Private.cpp
new file mode 100644
index 0000000..c5b5b30
--- /dev/null
+++ b/src/crepe/util/Private.cpp
@@ -0,0 +1,29 @@
+#include "Private.h"
+
+using namespace crepe;
+
+bool Private::empty() const noexcept {
+ return this->instance == nullptr;
+}
+
+Private::~Private() {
+ if (this->instance == nullptr) return;
+ this->destructor(this->instance);
+}
+
+Private::Private(Private && other) {
+ *this = std::move(other);
+}
+
+Private & Private::operator=(Private && other) {
+ // TODO: ideally this function checks for self-assignment
+ this->instance = other.instance;
+ this->destructor = other.destructor;
+ this->type = other.type;
+
+ other.instance = nullptr;
+ other.destructor = [](void*){};
+
+ return *this;
+}
+