Owned(P *parent, Args &&... args): Owned(Handle<P>::from_object(parent), std::forward<Args>(args)...) { }
Owned(Owned &&other): Handle<T>(other) { other.ptr = nullptr; }
- Owned &operator=(Owned &&other);
+
+ template<typename U>
+ requires std::is_base_of_v<T, U>
+ Owned(Owned<U> &&other): Handle<T>(other) { other.ptr = nullptr; }
+
+ Owned &operator=(Owned &&other) { assign(std::move(other)); return *this; }
+
+ template<typename U>
+ requires std::is_base_of_v<T, U>
+ Owned &operator=(Owned<U> &&other) { assign(std::move(other)); return *this; }
+
~Owned() { destroy(); }
private:
+ template<typename U>
+ void assign(Owned<U> &&);
+
template<typename O>
static Stage &get_stage(O &);
}
template<typename T>
-Owned<T> &Owned<T>::operator=(Owned &&other)
+template<typename U>
+void Owned<T>::assign(Owned<U> &&other)
{
destroy();
this->ptr = other.ptr;
other.ptr = nullptr;
-
- return *this;
}
template<typename T>