diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-11 13:58:19 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-11 13:58:19 +0100 |
commit | d228d4b3856606ad4395723b2703759a0ebe9832 (patch) | |
tree | bfd3019ca2c9bec258fffca9a9204ddc88768264 /src/crepe/util/OptionalRef.hpp | |
parent | 770496ee9d0e45480c0e0f8951adb8eee247bfe1 (diff) | |
parent | c45b60941b82dec2097d958b396a117b1634eada (diff) |
Merge branch 'master' into loek/replay
Diffstat (limited to 'src/crepe/util/OptionalRef.hpp')
-rw-r--r-- | src/crepe/util/OptionalRef.hpp | 7 |
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; |