Add move version of rcp_dynamic_cast()

This commit is contained in:
josh committed 2026-02-24 17:17:34 -05:00
1 parent 69ecab39f2
commit 627661158e
2 files changed
+43

No files matched your search

+17
View File
@@ -174,6 +174,9 @@ public:
{
return T::create(std::forward<Args>(args)...);
}
template <typename V, typename W>
friend rcp<V> rcp_dynamic_cast(rcp<W> && other);
};
template <typename T, typename U>
@@ -182,6 +185,20 @@ rcp<T> rcp_dynamic_cast(const rcp<U> & other)
return rcp<T>(dynamic_cast<T *>(other.get_raw()));
}
template <typename T, typename U>
rcp<T> rcp_dynamic_cast(rcp<U> && other)
{
T * p = dynamic_cast<T *>(other.ptr);
if (p)
{
other.ptr = nullptr;
rcp<T> result;
result.ptr = p;
return result;
}
return rcp<T>();
}
#define rcp_managed_root(classname) \
public: \
void rcp_inc() const \