diff --git a/Core/Types/object_ptr.hpp b/Core/Types/object_ptr.hpp index 3b8414b..aa1146f 100644 --- a/Core/Types/object_ptr.hpp +++ b/Core/Types/object_ptr.hpp @@ -154,9 +154,19 @@ static void add_owner(object_ptr& ptr) if (ptr_) counter::remove_object(ptr_); } - Ty* get() const noexcept { return ptr_.load(); } - Ty& operator*() const noexcept { return *ptr_; } - Ty* operator->() const noexcept { return ptr_.load(); } + Ty* get() const { return ptr_.load(); } + Ty& operator*() const + { + if (!ptr_.load()) + throw std::runtime_error("Null pointer"); + return *ptr_; + } + Ty* operator->() const + { + if (!ptr_.load()) + throw std::runtime_error("Null pointer"); + return ptr_.load(); + } operator bool() const noexcept { return ptr_.load() != nullptr; } object_ptr& operator=(const object_ptr& ptr) {