Skip to content

Instantly share code, notes, and snippets.

@Cylix
Created October 19, 2020 05:58
Show Gist options
  • Save Cylix/6ece71afdd3ca3a8d385a1f00b289b38 to your computer and use it in GitHub Desktop.
Save Cylix/6ece71afdd3ca3a8d385a1f00b289b38 to your computer and use it in GitHub Desktop.
Reflection in C++14 - Reflection #2
template <typename ReturnType, typename... Params>
struct reflection_maker;
template <typename ReturnType, typename... Params>
struct reflection_maker<ReturnType(Params...)> {
static ReturnType invoke(const std::string& class_name, const std::string& function_name, Params... params) {
return reflection_manager::get_instance().reflect<ReturnType, Params...>(class_name, function_name, params...);
}
};
int main(void) {
reflection_maker<void(int, double)>::invoke("SomeClass", "some_fct", 1, 4.2); // will call SomeClass().some_fct(1, 4.2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment