Skip to content

Instantly share code, notes, and snippets.

@heejune
Created August 16, 2017 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heejune/06fcbf25c6bd8eae458ac6b9c362402b to your computer and use it in GitHub Desktop.
Save heejune/06fcbf25c6bd8eae458ac6b9c362402b to your computer and use it in GitHub Desktop.
struct routing_delegator
{
routing_delegator() {} // default
routing_delegator(std::vector<std::string> r) : ruleset(r) {}
// register functor handler
template <typename F>
void to(F&& f)
{
routing_data = std::make_unique<typed_routing_recored<decltype(&F::operator())>>(f);
}
// invoke handler
template <typename... Args>
reply handle(Args&&... args)
{
auto tuple = std::make_tuple<Args...>(args...);
return routing_data->handle(&tuple);
}
std::unique_ptr<routing_record> routing_data = nullptr;
std::vector<std::string> ruleset;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment