aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe/util')
-rw-r--r--src/crepe/util/Private.cpp5
-rw-r--r--src/crepe/util/Private.h6
-rw-r--r--src/crepe/util/Private.hpp4
3 files changed, 11 insertions, 4 deletions
diff --git a/src/crepe/util/Private.cpp b/src/crepe/util/Private.cpp
index c5b5b30..cb4cb5b 100644
--- a/src/crepe/util/Private.cpp
+++ b/src/crepe/util/Private.cpp
@@ -27,3 +27,8 @@ Private & Private::operator=(Private && other) {
return *this;
}
+Private::Private(const Private & other) { }
+Private & Private::operator=(const Private & other) {
+ return *this;
+}
+
diff --git a/src/crepe/util/Private.h b/src/crepe/util/Private.h
index fc3728f..6dd28bb 100644
--- a/src/crepe/util/Private.h
+++ b/src/crepe/util/Private.h
@@ -9,16 +9,16 @@ class Private {
public:
Private() = default;
~Private();
+ Private(const Private &);
Private(Private &&);
+ Private & operator=(const Private &);
Private & operator=(Private &&);
- Private(const Private &) = delete;
- Private & operator=(const Private &) = delete;
template <typename T>
T & get();
template <typename T, typename... Args>
- void set(Args &&... args);
+ T & set(Args &&... args);
bool empty() const noexcept;
diff --git a/src/crepe/util/Private.hpp b/src/crepe/util/Private.hpp
index 30c8146..d6ab23f 100644
--- a/src/crepe/util/Private.hpp
+++ b/src/crepe/util/Private.hpp
@@ -8,13 +8,15 @@
namespace crepe {
template <typename T, typename... Args>
-void Private::set(Args &&... args) {
+T & Private::set(Args &&... args) {
+ if (!this->empty()) this->destructor(this->instance);
T * instance = new T(std::forward<Args>(args)...);
this->instance = static_cast<void*>(instance);
this->destructor = [](void * instance) {
delete static_cast<T*>(instance);
};
this->type = typeid(T);
+ return *instance;
}
template <typename T>