From 60c3077cd642217a1fb4d2f55cb646cd6f136be0 Mon Sep 17 00:00:00 2001 From: DH Date: Sat, 11 Nov 2023 16:22:08 +0300 Subject: [PATCH] [orbis-kernel] rc: add cast utilities --- orbis-kernel/include/orbis/utils/Rc.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/orbis-kernel/include/orbis/utils/Rc.hpp b/orbis-kernel/include/orbis/utils/Rc.hpp index f728b849d..8992a375f 100644 --- a/orbis-kernel/include/orbis/utils/Rc.hpp +++ b/orbis-kernel/include/orbis/utils/Rc.hpp @@ -124,6 +124,13 @@ public: bool operator==(std::nullptr_t) const { return m_ref == nullptr; } auto operator<=>(const T *other) const { return m_ref <=> other; } auto operator<=>(const Ref &other) const = default; + + template Ref cast() { + return Ref(dynamic_cast(m_ref)); + } + template Ref staticCast() { + return Ref(static_cast(m_ref)); + } }; // template