Created
August 16, 2017 13:57
-
-
Save heejune/06fcbf25c6bd8eae458ac6b9c362402b 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_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