From 36d7d156b7be58708e351adf2ddd94c10338319f Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Tue, 16 Dec 2025 10:12:43 +0100 Subject: feat: libSystem/Verify.h API tweaks and breaking changes. Signed-off-by: Amlal El Mahrouss --- src/libSystem/SystemKit/Verify.h | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/libSystem/SystemKit/Verify.h') diff --git a/src/libSystem/SystemKit/Verify.h b/src/libSystem/SystemKit/Verify.h index b99dbecc..c584ac82 100644 --- a/src/libSystem/SystemKit/Verify.h +++ b/src/libSystem/SystemKit/Verify.h @@ -14,19 +14,26 @@ namespace LibSystem::Verify { /// @author 0xf00sec, and Amlal El Mahrouss /// @brief safe cast operator. -template +template inline R sys_safe_cast(const T* ptr) { - _rtl_assert(ptr, "safe cast failed!"); - return static_cast(const_cast(ptr)); + ::_rtl_assert(ptr, "safe cast failed!"); + return static_cast(const_cast(ptr)); } -template -struct must_cast_traits { +template +inline Void sys_safe_cast(const T* ptr) = delete; + +template +struct is_castable { + using return_type = U; + constexpr static BOOL value = false; }; -template -struct must_cast_traits { +template +struct is_castable { + using return_type = T; + constexpr static BOOL value = true; }; @@ -34,7 +41,7 @@ struct must_cast_traits { /// @brief Safe constexpr cast. template constexpr R* sys_constexpr_cast(T* ptr) { - static_assert(must_cast_traits::value, "constexpr cast failed! types are mismatching!"); + static_assert(is_castable::value, "types cannot be casted."); return static_cast(ptr); } } // namespace LibSystem::Verify -- cgit v1.2.3