Created
August 16, 2017 13:57
-
-
Save heejune/d17b0255251363343adc1a673404dd11 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct routing_record | |
{ | |
virtual reply handle(void*) abstract; | |
}; | |
template <typename T> | |
struct typed_routing_recored; | |
template <typename RetType, typename classTy, typename... ArgType> | |
struct typed_routing_recored<RetType(classTy::*)(ArgType...) const> : public routing_record | |
{ | |
std::function<RetType(ArgType...)> stdfn; | |
typed_routing_recored(RetType(*pfn)(ArgType...)) | |
: stdfn(pfn) {} | |
virtual reply handle(void* args) override | |
{ | |
static const std::size_t typesize = sizeof...(ArgType); | |
auto tuple = static_cast<std::tuple<typename std::decay<ArgType>::type...>*> (args); | |
return _handle(*tuple, std::index_sequence_for<ArgType...>()); | |
} | |
template <std::size_t... Is> | |
RetType _handle(const std::tuple<ArgType...>& tuple, std::index_sequence<Is...>) | |
{ | |
return (stdfn)(std::get<Is>(tuple)...); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment