From e01ff2f396bce166c9481e7d258895effa395fdc Mon Sep 17 00:00:00 2001 From: sha512sum Date: Mon, 15 Apr 2024 12:40:51 +0000 Subject: [PATCH] template for socket type in network facade functions --- include/cserver/engine/network.hpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/include/cserver/engine/network.hpp b/include/cserver/engine/network.hpp index 92cc746..33713ce 100644 --- a/include/cserver/engine/network.hpp +++ b/include/cserver/engine/network.hpp @@ -114,24 +114,24 @@ inline constexpr auto DynamicBuffer(T&& arg) -> decltype(boost::asio::dynamic_bu }; -template -inline constexpr auto AsyncWrite(TcpSocket& socket, Buffer buffer) -> Task<> { - return boost::asio::async_write(socket.impl, std::move(buffer), boost::asio::use_awaitable); +template +inline constexpr auto AsyncWrite(Socket&& socket, Buffer buffer) -> Task<> { + return boost::asio::async_write(std::forward(socket).impl, std::move(buffer), boost::asio::use_awaitable); }; -template -inline constexpr auto AsyncWrite(TcpSocket& socket, Buffer buffer, CompletionCondition completion) -> Task<> { - return boost::asio::async_write(socket.impl, std::move(buffer), std::move(completion), boost::asio::use_awaitable); +template +inline constexpr auto AsyncWrite(Socket&& socket, Buffer buffer, CompletionCondition completion) -> Task<> { + return boost::asio::async_write(std::forward(socket).impl, std::move(buffer), std::move(completion), boost::asio::use_awaitable); }; -template -inline constexpr auto AsyncRead(TcpSocket& socket, Buffer buffer) -> Task<> { - return boost::asio::async_read(socket.impl, std::move(buffer), boost::asio::use_awaitable); +template +inline constexpr auto AsyncRead(Socket&& socket, Buffer buffer) -> Task<> { + return boost::asio::async_read(std::forward(socket).impl, std::move(buffer), boost::asio::use_awaitable); }; -template -inline constexpr auto AsyncRead(TcpSocket& socket, Buffer buffer, CompletionCondition completion) -> Task<> { - return boost::asio::async_read(socket.impl, std::move(buffer), std::move(completion), boost::asio::use_awaitable); +template +inline constexpr auto AsyncRead(Socket&& socket, Buffer buffer, CompletionCondition completion) -> Task<> { + return boost::asio::async_read(std::forward(socket).impl, std::move(buffer), std::move(completion), boost::asio::use_awaitable); }; template