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. More... | |
static const detail::bind_as_ptr | bind_as_ptr |
The bind_as_ptr policy will bind a member object as pointer type. More... | |
Detailed Description
The prop class groups all policies that can be used during registration of properties.
Member Data Documentation
|
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()
{
Foo obj;
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;
}
|
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()
{
Foo obj;
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;
}
The documentation for this struct was generated from the following file: