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 DISABLE_COMPILER_GCC_WARNING_START (
"GCC diagnostic ignored \"-Wunused-local-typedefs\"");
21 using DECAYED_T = conditional_t<is_reference_v<T>, remove_cvref_t<T>, remove_pointer_t<remove_cvref_t<T>>>;
22 DISABLE_COMPILER_GCC_WARNING_END (
"GCC diagnostic ignored \"-Wunused-local-typedefs\"");
23 if constexpr (is_reference_v<T>) {
25 Require (
static_cast<const DECAYED_T*
> (&arg) ==
dynamic_cast<const DECAYED_T*
> (&arg));
29 Require (
static_cast<T
> (arg) ==
dynamic_cast<T
> (arg));
33 return static_cast<T
> (arg);
41 template <
typename T,
typename T1>
45 if (
const auto p = UncheckedDynamicCast<T*> (arg.get ())) {
46 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...