Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.