rttr::policy::prop Struct Reference
The prop class groups all policies that can be used during registration of properties. More...
#include <policy.h>
Static Public Attributes | |
static const detail::as_reference_wrapper | as_reference_wrapper |
The as_reference_wrapper policy will bind a member object as std::reference_wrapper type. | |
static const detail::bind_as_ptr | bind_as_ptr |
The bind_as_ptr policy will bind a member object as pointer type. | |
Detailed Description
The prop class groups all policies that can be used during registration of properties.
Member Data Documentation
◆ as_reference_wrapper
|
static |
The as_reference_wrapper policy will bind a member object as std::reference_wrapper type.
This can be useful when binding big data types, like arrays, to avoid copies during get/set of the property.
See following example code:
using namespace rttr;
struct Foo
{
std::vector<int> vec;
};
{
registration::class_<Foo>("Foo")
.property("vec", &Foo::vec)
(
);
}
int main()
{
property prop = type::get<Foo>().get_property("vec");
std::cout << var.is_type<std::reference_wrapper<std::vector<int>>>(); // prints "true"
prop.set_value(obj, var); // not really necessary, but remark that now a std::reference_wrapper<std::vector<int>> is expected
return 0;
}
The array_range class provides a view into an underlying data structure with lower and upper limits.
Definition array_range.h:64
The class_ is used to register classes to RTTR.
Definition registration.h:130
bind< detail::prop, Class_Type, A, acc_level, Visitor_List > property(string_view name, A acc, acc_level level=acc_level())
Register a property to this class.
The variant class allows to store data of any type and convert between these types transparently.
Definition variant.h:199
Definition access_levels.h:34
#define RTTR_REGISTRATION
Use this macro to automatically register your reflection information to RTTR before main is called.
Definition registration.h:745
static const detail::as_reference_wrapper as_reference_wrapper
The as_reference_wrapper policy will bind a member object as std::reference_wrapper type.
Definition policy.h:193
◆ bind_as_ptr
|
static |
The bind_as_ptr policy will bind a member object as pointer type.
This can be useful when binding big data types, like arrays, to avoid copies during get/set of the property.
See following example code:
using namespace rttr;
struct Foo
{
std::vector<int> vec;
};
{
registration::class_<Foo>("Foo")
.property("vec", &Foo::vec)
(
);
}
int main()
{
property prop = type::get<Foo>().get_property("vec");
std::cout << var.is_type<std::vector<int>*>(); // prints "true"
prop.set_value(obj, var); // not really necessary, but remark that now a std::vector<int>* is expected
return 0;
}
static const detail::bind_as_ptr bind_as_ptr
The bind_as_ptr policy will bind a member object as pointer type.
Definition policy.h:158
The documentation for this struct was generated from the following file:
Generated on Fri Jan 26 2024 00:00:00 for rttr - 0.9.7 by doxygen.