28 #ifndef __RTTR_INSTANCE_H__
29 #define __RTTR_INSTANCE_H__
50 instance() : _data(nullptr), _type(impl::get_invalid_type()) {}
52 instance(variant& var)
53 : _data(var.get_raw_ptr()),
54 _type(var.get_raw_type())
58 instance(
const instance& other)
64 instance(instance&& other)
71 instance(
const T& data,
typename std::enable_if<!std::is_same<instance, T>::value >::type* = 0)
72 : _data(detail::get_void_ptr(data)),
73 _type(rttr::type::get<typename raw_type<T>::type>())
75 static_assert(!std::is_same<argument, T>::value,
"Don't use the instance class for forwarding an argument!");
79 instance(T& data,
typename std::enable_if<!std::is_same<instance, T>::value >::type* = 0)
80 : _data(detail::get_void_ptr(data)),
81 _type(rttr::type::get<typename raw_type<T>::type>())
83 static_assert(!std::is_same<argument, T>::value,
"Don't use the instance class for forwarding an argument!");
86 template<
typename TargetType>
87 TargetType* try_convert()
const
89 return (static_cast<TargetType*>(type::apply_offset(const_cast<instance*>(
this)->_data, _type, type::get<TargetType>())));
92 bool is_valid()
const {
return (_data !=
nullptr); }
93 operator bool()
const {
return (_data !=
nullptr); }
95 type get_type()
const {
return _type; }
98 instance& operator=(
const instance& other);
113 RTTR_INLINE static detail::instance empty_instance() {
return detail::instance(); }
116 #endif // __RTTR_INSTANCE_H__
This class holds the type information for any arbitrary object.
Definition: type.h:165
#define RTTR_INLINE
Definition: core_prerequisites.h:90