diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-11 16:28:37 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-11 16:28:37 +0100 |
commit | a108f7360e03cc7826ad4ed0cee464b1196fa456 (patch) | |
tree | 2de89843620b8ec65b99a56bd3c2428bef733852 /src/crepe/util/OptionalRef.hpp | |
parent | d80c98ee03e59e0c38e025a7fe83ab4c39115fb8 (diff) | |
parent | 78c4a8772526f40c531b5402b56932b0a41e22e8 (diff) |
Merge branch 'master' of https://github.com/lonkaars/crepe into wouter/text-component
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; |