aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/util
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-29 17:30:45 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-29 17:30:45 +0100
commit693355f55193cb2ea4c29616073227e37665afc1 (patch)
tree37d2bd3e916b909fbac58ae836e8001166edf384 /src/crepe/util
parentc59d460f12e1393e0ddbaaa1c6f5522eb12f8ff9 (diff)
more audio system WIP
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>