X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgame%2Fowned.h;fp=source%2Fgame%2Fowned.h;h=a30f040d58269019cd3634159100e7d2f8a976c3;hb=c71b8c2151e097f435c8f76ffa123cc71f9d12ec;hp=76a75521a47a0d04b1d02d0531e065144f026796;hpb=a5be9fabc4c8fb153f2176dfce93874d699f32a0;p=libs%2Fgame.git
diff --git a/source/game/owned.h b/source/game/owned.h
index 76a7552..a30f040 100644
--- a/source/game/owned.h
+++ b/source/game/owned.h
@@ -25,10 +25,23 @@ public:
Owned(P *parent, Args &&... args): Owned(Handle
::from_object(parent), std::forward(args)...) { }
Owned(Owned &&other): Handle(other) { other.ptr = nullptr; }
- Owned &operator=(Owned &&other);
+
+ template
+ requires std::is_base_of_v
+ Owned(Owned &&other): Handle(other) { other.ptr = nullptr; }
+
+ Owned &operator=(Owned &&other) { assign(std::move(other)); return *this; }
+
+ template
+ requires std::is_base_of_v
+ Owned &operator=(Owned &&other) { assign(std::move(other)); return *this; }
+
~Owned() { destroy(); }
private:
+ template
+ void assign(Owned &&);
+
template
static Stage &get_stage(O &);
@@ -68,14 +81,13 @@ Owned::Owned(Handle parent, Args &&... args)
}
template
-Owned &Owned::operator=(Owned &&other)
+template
+void Owned::assign(Owned &&other)
{
destroy();
this->ptr = other.ptr;
other.ptr = nullptr;
-
- return *this;
}
template