]> git.tdb.fi Git - libs/game.git/commitdiff
Tweak the constructors of Owned
authorMikko Rasa <tdb@tdb.fi>
Sat, 29 Oct 2022 17:24:39 +0000 (20:24 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 29 Oct 2022 17:24:39 +0000 (20:24 +0300)
This makes it not break if an Owned is passed as the first argument.

source/game/owned.h

index 620c6aab54e2114a7e3c718256fb794a92593d47..b305ae21d1aea7f371ab5b9a661f00f09153841b 100644 (file)
@@ -21,6 +21,10 @@ public:
        Owned(Handle<P>, Args &&...);
 
        template<typename P, typename... Args>
+       Owned(Owned<P> &p, Args &&... a): Owned(static_cast<Handle<P> &>(p), std::forward<Args>(a)...) { }
+
+       template<typename P, typename... Args>
+               requires(!std::is_const_v<P>)
        Owned(P &parent, Args &&... args): Owned(Handle<P>::from_object(&parent), std::forward<Args>(args)...) { }
 
        Owned(Owned &&other): Handle<T>(other) { other.ptr = nullptr; }