5namespace Stroika::Foundation::Debug {
12 template <
typename T,
typename T1>
15 static_assert (is_reference_v<T> or is_pointer_v<T>);
16 if constexpr (is_pointer_v<T>) {
17 Require (arg !=
nullptr);
20 using DECAYED_T [[maybe_unused]] = conditional_t<is_reference_v<T>, remove_cvref_t<T>, remove_pointer_t<remove_cvref_t<T>>>;
21 if constexpr (is_reference_v<T>) {
23 Require (
static_cast<const DECAYED_T*
> (&arg) ==
dynamic_cast<const DECAYED_T*
> (&arg));
27 Require (
static_cast<T
> (arg) ==
dynamic_cast<T
> (arg));
31 return static_cast<T
> (arg);
39 template <
typename T,
typename T1>
43 if (
const auto p = UncheckedDynamicCast<T*> (arg.get ())) {
44 return shared_ptr<T>{std::move (arg), p};
#define qStroika_Foundation_Debug_AssertionsChecked
The qStroika_Foundation_Debug_AssertionsChecked flag determines if assertions are checked and validat...
#define AssertMember(p, c)
T UncheckedDynamicCast(T1 &&arg) noexcept
return the same value as dynamic_cast<T> would have, except instead of checking nullptr,...
std::shared_ptr< T > UncheckedDynamicPointerCast(const std::shared_ptr< T1 > &arg) noexcept
Produce the same result as dynamic_pointer_cast if the successful case (non-null) - with better perfo...