28 #ifndef __RTTR_ARGUMENT_H__
29 #define __RTTR_ARGUMENT_H__
37 #include <type_traits>
54 argument() : _data(nullptr), _type(impl::get_invalid_type()) {}
55 argument(
const argument& other) : _data(other._data), _type(other._type) {}
56 argument(variant& var) : _data(var.get_ptr()), _type(var.get_type()) {}
57 argument(
const variant& var) : _data(var.get_ptr()), _type(var.get_type()) {}
58 argument(variant_array& var) : _data(var.get_ptr()), _type(var.get_type()) {}
59 argument(
const variant_array& var) : _data(var.get_ptr()), _type(var.get_type()) {}
62 argument(
const T& data,
typename std::enable_if<!std::is_same<argument, T>::value >::type* = 0)
63 : _data(reinterpret_cast<const void*>(std::addressof(data))),
64 _type(rttr::type::get<T>())
66 static_assert(!std::is_same<instance, T>::value,
"Don't use the argument class for forwarding an instance!");
70 argument(T& data,
typename std::enable_if<!std::is_same<argument, T>::value >::type* = 0)
71 : _data(reinterpret_cast<const void*>(std::addressof(data))),
72 _type(rttr::type::get<T>())
74 static_assert(!std::is_same<instance, T>::value,
"Don't use the argument class for forwarding an instance!");
78 bool is_type()
const {
return rttr::type::get<T>() == _type; }
79 type get_type()
const {
return _type; }
80 void* get_ptr()
const {
return const_cast<void *
>(_data); }
85 using raw_type =
typename std::remove_reference<T>::type;
86 return (*reinterpret_cast<raw_type*>(const_cast<void *>(_data)));
89 argument& operator=(
const argument& other)
104 #endif // __RTTR_ARGUMENT_H__
This class holds the type information for any arbitrary object.
Definition: type.h:165