aboutsummaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
Diffstat (limited to 'libs')
-rw-r--r--libs/kstd/kstd/bits/observer_ptr.hpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/libs/kstd/kstd/bits/observer_ptr.hpp b/libs/kstd/kstd/bits/observer_ptr.hpp
index d53ab5a0..d0c40549 100644
--- a/libs/kstd/kstd/bits/observer_ptr.hpp
+++ b/libs/kstd/kstd/bits/observer_ptr.hpp
@@ -160,6 +160,48 @@ namespace kstd
return observer_ptr<ElementType>{pointer};
}
+ template<typename T, typename U>
+ [[nodiscard]] constexpr auto static_pointer_cast(observer_ptr<U> const & other) noexcept -> observer_ptr<T>
+ {
+ return observer_ptr{static_cast<observer_ptr<T>::element_type *>(other.get())};
+ }
+
+ template<typename T, typename U>
+ [[nodiscard]] constexpr auto static_pointer_cast(observer_ptr<U> && other) noexcept -> observer_ptr<T>
+ {
+ return observer_ptr{static_cast<observer_ptr<T>::element_type *>(std::move(other).get())};
+ }
+
+ template<typename T, typename U>
+ [[nodiscard]] constexpr auto dynamic_pointer_cast(observer_ptr<U> const & other) noexcept -> observer_ptr<T> = delete;
+
+ template<typename T, typename U>
+ [[nodiscard]] constexpr auto dynamic_pointer_cast(observer_ptr<U> && other) noexcept -> observer_ptr<T> = delete;
+
+ template<typename T, typename U>
+ [[nodiscard]] constexpr auto const_pointer_cast(observer_ptr<U> const & other) noexcept -> observer_ptr<T>
+ {
+ return observer_ptr{const_cast<observer_ptr<T>::element_type *>(other.get())};
+ }
+
+ template<typename T, typename U>
+ [[nodiscard]] constexpr auto const_pointer_cast(observer_ptr<U> && other) noexcept -> observer_ptr<T>
+ {
+ return observer_ptr{const_cast<observer_ptr<T>::element_type *>(other.get())};
+ }
+
+ template<typename T, typename U>
+ [[nodiscard]] constexpr auto reinterpret_pointer_cast(observer_ptr<U> const & other) noexcept -> observer_ptr<T>
+ {
+ return observer_ptr{reinterpret_cast<observer_ptr<T>::element_type *>(other.get())};
+ }
+
+ template<typename T, typename U>
+ [[nodiscard]] constexpr auto reinterpret_pointer_cast(observer_ptr<U> && other) noexcept -> observer_ptr<T>
+ {
+ return observer_ptr{reinterpret_cast<observer_ptr<T>::element_type *>(other.get())};
+ }
+
} // namespace kstd
#endif \ No newline at end of file