X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgame%2Fowned.h;h=a30f040d58269019cd3634159100e7d2f8a976c3;hb=f4ca190e869b9d03bf4f8b7b002c65af9f56c0ad;hp=d6f9f17a9ce170d7456dbafe08b3e53fe1a29418;hpb=f377d216dfc44e36da3697557f38dfedcbec45d1;p=libs%2Fgame.git diff --git a/source/game/owned.h b/source/game/owned.h index d6f9f17..a30f040 100644 --- a/source/game/owned.h +++ b/source/game/owned.h @@ -22,17 +22,26 @@ public: Owned(Handle

, Args &&...); template - Owned(Owned

&p, Args &&... a): Owned(static_cast &>(p), std::forward(a)...) { } - - template - requires(!std::is_const_v

) - Owned(P &parent, Args &&... args): Owned(Handle

::from_object(&parent), std::forward(args)...) { } + 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 &); @@ -72,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