Open scarlink opened 5 years ago
I'm trying to attach external functions as methods to a type in order to extend what can I do on a type without touching the class definition, e.g:
struct myType { int data; RTTR_ENABLE() }
void dump_myType(myType* src) { ... } RTTR_REGISTRATION { rttr::registration::class_<myType>("myType") .constructor<>() .property("data", &myType::data) .method("dump", &dump_myType); }
And then i call it with:
myType t; method tdump = type::get(t).get_method("dump"); tdump.invoke(t,&t);
And it actually works, i also did this for integers, std::string and so on
RTTR_REGISTRATION { rttr::registration::class_<int>("int") .method("dump", &dump_int); }
Is this the correct way to achieve this behaviour?
I'm trying to attach external functions as methods to a type in order to extend what can I do on a type without touching the class definition, e.g:
struct myType { int data; RTTR_ENABLE() }
And then i call it with:
And it actually works, i also did this for integers, std::string and so on
Is this the correct way to achieve this behaviour?