]> git.tdb.fi Git - libs/game.git/blobdiff - source/game/handle.h
Allow null handles to be created from nullptr
[libs/game.git] / source / game / handle.h
index d384f35c3c1fae6f29b1871a4c955079078d3e75..2e544c7238e75ca7d5418c9f5c7a05c65e61081e 100644 (file)
@@ -23,13 +23,14 @@ protected:
 
 public:
        Handle() = default;
-
-       static Handle from_object(T *o) { Handle h; h.ptr = o; return h; }
+       Handle(nullptr_t) { }
 
        template<typename U>
                requires std::is_base_of_v<T, U>
        Handle(const Handle<U> &other): ptr(other.ptr) { }
 
+       static Handle from_object(T *o) { Handle h; h.ptr = o; return h; }
+
        T *get() const { return ptr; }
        T &operator*() const { return *ptr; }
        T *operator->() const { return ptr; }