diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-02 16:13:08 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-02 16:13:08 +0100 |
commit | 7a8657dfe019104aced61a5b63e63f61ad919f7a (patch) | |
tree | fd8e7aa148aac0a4f50fca8fe05e5016dfd16e47 /src/crepe/util/Private.hpp | |
parent | b8194e02679dc88f5c0a240da83a4700ec5200cf (diff) |
remove `Private`
Diffstat (limited to 'src/crepe/util/Private.hpp')
-rw-r--r-- | src/crepe/util/Private.hpp | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/src/crepe/util/Private.hpp b/src/crepe/util/Private.hpp deleted file mode 100644 index b2174c0..0000000 --- a/src/crepe/util/Private.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#include <format> -#include <stdexcept> - -#include "Private.h" - -namespace crepe { - -template <typename T, typename... 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> -T & Private::get() const { - using namespace std; - if (this->empty()) throw out_of_range("Private: get() called on empty object"); - type_index requested_type = typeid(T); - if (this->type != requested_type) - throw logic_error(format("Private: get() called with [T = {}] (actual is [T = {}])", - requested_type.name(), this->type.name())); - return *static_cast<T *>(this->instance); -} - -} // namespace crepe |