From 1e7c176f923aebadcb3a039b0aa0a736027b9bb6 Mon Sep 17 00:00:00 2001 From: Marcelo Zimbres Date: Sat, 3 Dec 2022 22:29:04 +0100 Subject: [PATCH] Removes dependency on Boost.Hana. --- README.md | 6 ++++ benchmarks/cpp/asio/echo_server_direct.cpp | 2 +- include/aedis/resp3/request.hpp | 37 ++++++++++------------ 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index cf01136e..f1d02a4e 100644 --- a/README.md +++ b/README.md @@ -875,8 +875,14 @@ Acknowledgement to people that helped shape Aedis ## Changelog +### master + +* Removes dependency on Boost.Hana. + ### v1.3.0-1 +* Upgrades to Boost 1.80.0 + * Removes automatic sending of the `HELLO` command. This can't be implemented properly without bloating the connection class. It is now a user responsability to send HELLO. Requests that contain it have diff --git a/benchmarks/cpp/asio/echo_server_direct.cpp b/benchmarks/cpp/asio/echo_server_direct.cpp index f29617e6..e8289862 100644 --- a/benchmarks/cpp/asio/echo_server_direct.cpp +++ b/benchmarks/cpp/asio/echo_server_direct.cpp @@ -33,7 +33,7 @@ awaitable_type echo(tcp_socket socket) std::size_t n = co_await socket.async_read_some(net::buffer(data), use_awaitable); co_await async_write(socket, net::buffer(data, n), use_awaitable); } - } catch (std::exception const& e) { + } catch (std::exception const&) { //std::printf("echo Exception: %s\n", e.what()); } } diff --git a/include/aedis/resp3/request.hpp b/include/aedis/resp3/request.hpp index 84e041b8..71b0596d 100644 --- a/include/aedis/resp3/request.hpp +++ b/include/aedis/resp3/request.hpp @@ -11,7 +11,6 @@ #include #include -#include #include #include @@ -80,6 +79,21 @@ struct add_bulk_impl { } }; +template +struct add_bulk_impl> { + template + static void add(Request& to, std::tuple const& t) + { + auto f = [&](auto const&... vs) + { + using namespace aedis::resp3; + (to_bulk(to, vs), ...); + }; + + std::apply(f, t); + } +}; + template struct add_bulk_impl> { template @@ -91,23 +105,6 @@ struct add_bulk_impl> { } }; -template -struct add_bulk_impl> { - template - static void add(Request& to, boost::hana::tuple const& from) - { - using boost::hana::for_each; - - // Fold expressions is C++17 so we use hana. - //(detail::add_bulk(*request_, args), ...); - - for_each(from, [&](auto const& e) { - using namespace aedis::resp3; - to_bulk(to, e); - }); - } -}; - template void add_header(Request& to, type t, std::size_t size) { @@ -264,14 +261,12 @@ public: template void push(boost::string_view cmd, Ts const&... args) { - using boost::hana::for_each; - using boost::hana::make_tuple; using resp3::type; auto constexpr pack_size = sizeof...(Ts); detail::add_header(payload_, type::array, 1 + pack_size); detail::add_bulk(payload_, cmd); - detail::add_bulk(payload_, make_tuple(args...)); + detail::add_bulk(payload_, std::tie(std::forward(args)...)); check_cmd(cmd); }