aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/util/OptionalRef.hpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-12-07 16:01:19 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-12-07 16:01:19 +0100
commit2e6fcb1d048edd13a2ec69ddd226fc8ebabc2389 (patch)
tree249b4633d24339467de9d0d008dce602a9cbd2cc /src/crepe/util/OptionalRef.hpp
parentf19f37ae3eff84161f86e62a26fbd8b68f8f91a9 (diff)
add SaveManager to Script
Diffstat (limited to 'src/crepe/util/OptionalRef.hpp')
-rw-r--r--src/crepe/util/OptionalRef.hpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/crepe/util/OptionalRef.hpp b/src/crepe/util/OptionalRef.hpp
index 4608c9e..5e36b3a 100644
--- a/src/crepe/util/OptionalRef.hpp
+++ b/src/crepe/util/OptionalRef.hpp
@@ -19,6 +19,13 @@ OptionalRef<T>::operator T &() const {
}
template <typename T>
+T * OptionalRef<T>::operator->() const {
+ if (this->ref == nullptr)
+ throw std::runtime_error("OptionalRef: attempt to dereference nullptr");
+ return this->ref;
+}
+
+template <typename T>
OptionalRef<T> & OptionalRef<T>::operator=(T & ref) {
this->ref = &ref;
return *this;