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
◆ 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()
{
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;
}
◆ 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()
{
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:
bind< detail::prop, Class_Type, A, acc_level > property(string_view name, A acc, acc_level level=acc_level())
Register a property to this class.
bool is_type() const
Returns true if the containing variant data is of the given template type T.
Definition: access_levels.h:34
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
The class_ is used to register classes to RTTR.
Definition: registration.h:130
#define RTTR_REGISTRATION
Use this macro to automatically register your reflection information to RTTR before main is called.
Definition: registration.h:745
The variant class allows to store data of any type and convert between these types transparently.
Definition: variant.h:198
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
Generated on Sun Dec 27 2020 08:16:23 for rttr - 0.9.6 by doxygen.