48 #ifndef _MIRA_VOIDCAST_H_ 49 #define _MIRA_VOIDCAST_H_ 51 #include <type_traits> 62 void* voidUpcastNormal(T* pointer)
65 Tc* p =
const_cast<Tc*
>(pointer);
66 return static_cast<void*
>(p);
70 T* voidDowncastNormal(
void* pointer)
72 return static_cast<T*
>(pointer);
80 void* voidUpcastPolymorphic(T* pointer)
83 Tc* p =
const_cast<Tc*
>(pointer);
85 return static_cast<void*
>(obj);
89 T* voidDowncastPolymorphic(
void* pointer)
92 T* p =
dynamic_cast<T*
>(obj);
110 if constexpr (std::is_base_of_v<mira::Object, T>) {
111 return voidUpcastPolymorphic(pointer);
114 return voidUpcastNormal(pointer);
126 if constexpr (std::is_base_of_v<mira::Object, T>) {
127 return voidDowncastPolymorphic<T>(pointer);
130 return voidDowncastNormal<T>(pointer);
Definition: StlCollections.h:61
PropertyHint type(const std::string &t)
Sets the attribute "type" to the specified value.
Definition: PropertyHint.h:295
T * void_downcast(void *pointer)
Safe cast for casting from a void pointer to a derived pointer T* while taking care of polymorphism a...
Definition: VoidCast.h:124
The object class acts as a generic base class for classes which should be used with the classFactory...
Definition: Object.h:144
$Defines object class as base class for classFactory compatible classes$.
void * void_upcast(T *pointer)
Safe cast for casting from a pointer upwards to void* while taking care of polymorphism and multiple ...
Definition: VoidCast.h:108