]> git.tdb.fi Git - libs/game.git/commitdiff
Allow null handles to be created from nullptr
authorMikko Rasa <tdb@tdb.fi>
Sat, 22 Oct 2022 16:04:53 +0000 (19:04 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 22 Oct 2022 16:05:08 +0000 (19:05 +0300)
source/game/handle.h
source/game/root.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; }
index f4ed18edc1b509510441e36c4306de8de2d3ce0f..4f7ea76101c4b831d2be304b922a047e508b4f19 100644 (file)
@@ -13,7 +13,7 @@ private:
        Stage &stage;
 
 public:
-       Root(Stage &s): Entity(Handle<Entity>()), stage(s) { }
+       Root(Stage &s): Entity(nullptr), stage(s) { }
 
        Stage &get_stage() const { return stage; }
 };