20#ifndef LIB_RTTI_UTILS_H_
21#define LIB_RTTI_UTILS_H_
36struct has_rtti : std::is_base_of<RTTI::Base, T> {};
44template <
typename... Ts>
45inline constexpr const bool all_have_rtti_v = (has_rtti_v<Ts> && ...);
52template <
typename T,
typename R =
void>
58template <
typename... Ts>
59using enable_if_all_have_rtti_t = std::enable_if_t<all_have_rtti_v<Ts...>,
void>;
66template <
typename T,
typename R =
void>
71template <
typename To,
typename = enable_if_has_rtti_t<To>>
73 template <
typename From,
typename = enable_if_has_rtti_t<From>>
74 To *operator()(From *obj)
const {
75 return obj ? obj->template to<To>() :
nullptr;
78 template <
typename From,
typename = enable_if_has_rtti_t<From>>
79 const To *operator()(
const From *obj)
const {
80 return obj ? obj->template to<To>() :
nullptr;
84template <
typename... Targets>
88 static_assert(
sizeof...(Targets) > 0,
89 "At least one target type needs to be given for RTTI::is");
90 static_assert(all_have_rtti_v<Targets...>,
91 "All types in RTTI::is<Ts> need to be custom-rtti-enabled");
93 template <
typename From,
typename = enable_if_has_rtti_t<From>>
94 bool operator()(
const From *obj)
const {
95 return obj && (obj->template is<Targets>() || ...);
116template <
typename To>
130template <
typename Target>
142template <
typename... Targets>
Definition rtti_utils.h:87
Definition rtti_utils.h:72
Definition rtti_utils.h:53
Definition rtti_utils.h:36