13 #include <type_traits>
19 #if defined(ARMNN_POLYMORPHIC_CAST_TESTABLE)
20 # define ARMNN_POLYMORPHIC_CAST_CHECK_METHOD(cond) ConditionalThrow<std::bad_cast>(cond)
22 # define ARMNN_POLYMORPHIC_CAST_CHECK_METHOD(cond) ARMNN_ASSERT(cond)
26 #if !defined(NDEBUG) || defined(ARMNN_POLYMORPHIC_CAST_TESTABLE)
27 # define ARMNN_POLYMORPHIC_CAST_CHECK(cond) ARMNN_POLYMORPHIC_CAST_CHECK_METHOD(cond)
29 # define ARMNN_POLYMORPHIC_CAST_CHECK(cond) // release builds dont check the cast
36 template <
class T1,
class T2>
39 return std::static_pointer_cast<T1>(sp);
43 template <
class T1,
class T2>
46 return std::dynamic_pointer_cast<T1>(sp);
50 template<
class T1,
class T2>
53 return static_cast<T1*
>(ptr);
57 template<
class T1,
class T2>
60 return dynamic_cast<T1*
>(ptr);
73 template<
typename DestType,
typename SourceType>
76 static_assert(std::is_pointer<DestType>::value,
77 "PolymorphicDowncast only works with pointer types.");
80 return static_cast<DestType
>(value);
92 template<
typename DestType,
typename SourceType>
97 return utility::StaticPointerCast<DestType>(value);