diff options
author | JAROWMR <jarorutjes07@gmail.com> | 2024-12-14 11:40:33 +0100 |
---|---|---|
committer | JAROWMR <jarorutjes07@gmail.com> | 2024-12-14 11:40:33 +0100 |
commit | 061b2b8ab9aba67c1467cdd163fb7a04de95f4f1 (patch) | |
tree | e1960a83461e0d83a7027a88404af1a7c70f6dcd /src/crepe/util/OptionalRef.hpp | |
parent | fd2ebb54d0c2b269c15fc84a4ac77993efc917d7 (diff) | |
parent | b9fc66f6922b1f40f2dbe14e8dfc4caa469654bc (diff) |
Merge branch 'master' of github.com:lonkaars/crepe into jaro/collision-system
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; |