From 3f1c768e2d5b5e51dec08499d6a877220f33d7a6 Mon Sep 17 00:00:00 2001 From: Determinant Date: Fri, 3 Aug 2018 13:52:09 -0400 Subject: rename handler_bind and move to type.h --- include/salticidae/network.h | 9 ++------- include/salticidae/type.h | 5 +++++ 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/salticidae/network.h b/include/salticidae/network.h index c7b7f66..63c83be 100644 --- a/include/salticidae/network.h +++ b/include/salticidae/network.h @@ -32,11 +32,6 @@ namespace salticidae { -template -inline auto handler_bind(ReturnType(ClassType::* f)(Args...), FArgs&&... fargs) { - return std::function(std::bind(f, std::forward(fargs)...)); -} - /** Network of nodes who can send async messages. */ template class MsgNetwork: public ConnPool { @@ -527,8 +522,8 @@ template void PeerNetwork::listen(NetAddr listen_addr) { MsgNet::listen(listen_addr); listen_port = listen_addr.port; - this->reg_handler(handler_bind(&PeerNetwork::msg_ping, this, _1, _2)); - this->reg_handler(handler_bind(&PeerNetwork::msg_pong, this, _1, _2)); + this->reg_handler(generic_bind(&PeerNetwork::msg_ping, this, _1, _2)); + this->reg_handler(generic_bind(&PeerNetwork::msg_pong, this, _1, _2)); } template diff --git a/include/salticidae/type.h b/include/salticidae/type.h index 13d3071..c454265 100644 --- a/include/salticidae/type.h +++ b/include/salticidae/type.h @@ -79,6 +79,11 @@ struct log2<1> { enum { value = 0 }; }; +template +inline auto generic_bind(ReturnType(ClassType::* f)(Args...), FArgs&&... fargs) { + return std::function(std::bind(f, std::forward(fargs)...)); +} + } #endif -- cgit v1.2.3-70-g09d2