From 9503d832dd14b2c05183c5182dea5bcdd52310ff Mon Sep 17 00:00:00 2001 From: Takatoshi Kondo Date: Thu, 27 Nov 2025 10:20:09 +0900 Subject: [PATCH] Fixed #438. Removed unintentional copy requiment from some of async functions parameter. --- CHANGELOG.adoc | 6 ++ README.md | 2 +- .../async_mqtt/asio_bind/impl/client_auth.hpp | 60 ++++++++--------- .../asio_bind/impl/client_disconnect.hpp | 60 ++++++++--------- .../asio_bind/impl/client_publish.hpp | 60 ++++++++--------- .../asio_bind/impl/client_start.hpp | 64 ++++++++++--------- .../asio_bind/impl/client_subscribe.hpp | 60 ++++++++--------- .../asio_bind/impl/client_unsubscribe.hpp | 60 ++++++++--------- .../impl/endpoint_underlying_handshake.hpp | 18 +++--- 9 files changed, 205 insertions(+), 185 deletions(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 1c92d8314..4634bc7d1 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -2,6 +2,12 @@ = History +== 10.2.7 +* Removed unintentional copy requiment from some of async functions parameter. #437 +* Rifined documents. #435 +* Added TLS Websocket verify none port to broker for browser. #434 +* Added Cerfiticate file's digitalSignature to keyUsage. #432 + == 10.2.6 * Fixed wss connection from Web Browser handshake failed problem. #431 * Changed trial broker on `mqtt.redboltz.net` ws and wss port. #430 diff --git a/README.md b/README.md index 9c15597ac..359c6a5fa 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ - I/O independent (also known as Sans-I/O) MQTT protocol library for C++17. - Asynchronous MQTT communication library using the MQTT protocol library and Boost.Asio. -Version 10.2.6 [![Actions Status](https://github.com/redboltz/async_mqtt/workflows/CI/badge.svg)](https://github.com/redboltz/async_mqtt/actions)[![codecov](https://codecov.io/gh/redboltz/async_mqtt/branch/main/graph/badge.svg)](https://codecov.io/gh/redboltz/async_mqtt) +Version 10.2.7 [![Actions Status](https://github.com/redboltz/async_mqtt/workflows/CI/badge.svg)](https://github.com/redboltz/async_mqtt/actions)[![codecov](https://codecov.io/gh/redboltz/async_mqtt/branch/main/graph/badge.svg)](https://codecov.io/gh/redboltz/async_mqtt) ## Document diff --git a/include/async_mqtt/asio_bind/impl/client_auth.hpp b/include/async_mqtt/asio_bind/impl/client_auth.hpp index d67abb7b1..d042176b2 100644 --- a/include/async_mqtt/asio_bind/impl/client_auth.hpp +++ b/include/async_mqtt/asio_bind/impl/client_auth.hpp @@ -88,37 +88,39 @@ client::async_auth(Args&&... args) { } } else { - auto all = hana::tuple(std::forward(args)...); - auto back = hana::back(all); - auto rest = hana::drop_back(all, hana::size_c<1>); - return hana::unpack( - std::move(rest), - [&](auto&&... rest_args) { - static_assert( - std::is_constructible_v< - auth_packet, - decltype(rest_args)... - >, - "v5::auth_packet is not constructible" - ); - try { - return impl_type::async_auth( - impl_, - error_code{}, - auth_packet{std::forward(rest_args)...}, - force_move(back) - ); - } - catch (system_error const& se) { - return impl_type::async_auth( - impl_, - se.code(), - std::nullopt, - force_move(back) + return [this](auto&&... all_args) { + auto all = hana::make_tuple(std::forward(all_args)...); + constexpr auto N = sizeof...(all_args); + auto back = hana::at_c(force_move(all)); + return hana::unpack( + hana::drop_back(force_move(all), hana::size_c<1>), + [this, back = force_move(back)](auto&&... rest_args) mutable { + static_assert( + std::is_constructible_v< + auth_packet, + decltype(rest_args)... + >, + "v5::auth_packet is not constructible" ); + try { + return impl_type::async_auth( + impl_, + error_code{}, + auth_packet{std::forward(rest_args)...}, + force_move(back) + ); + } + catch (system_error const& se) { + return impl_type::async_auth( + impl_, + se.code(), + std::nullopt, + force_move(back) + ); + } } - } - ); + ); + }(std::forward(args)...); } } diff --git a/include/async_mqtt/asio_bind/impl/client_disconnect.hpp b/include/async_mqtt/asio_bind/impl/client_disconnect.hpp index 88889220b..338367f44 100644 --- a/include/async_mqtt/asio_bind/impl/client_disconnect.hpp +++ b/include/async_mqtt/asio_bind/impl/client_disconnect.hpp @@ -87,37 +87,39 @@ client::async_disconnect(Args&&... args) { } } else { - auto all = hana::tuple(std::forward(args)...); - auto back = hana::back(all); - auto rest = hana::drop_back(all, hana::size_c<1>); - return hana::unpack( - std::move(rest), - [&](auto&&... rest_args) { - static_assert( - std::is_constructible_v< - disconnect_packet, - decltype(rest_args)... - >, - "disconnect_packet is not constructible" - ); - try { - return impl_type::async_disconnect( - impl_, - error_code{}, - disconnect_packet{std::forward(rest_args)...}, - force_move(back) - ); - } - catch (system_error const& se) { - return impl_type::async_disconnect( - impl_, - se.code(), - std::nullopt, - force_move(back) + return [this](auto&&... all_args) { + auto all = hana::make_tuple(std::forward(all_args)...); + constexpr auto N = sizeof...(all_args); + auto back = hana::at_c(force_move(all)); + return hana::unpack( + hana::drop_back(force_move(all), hana::size_c<1>), + [this, back = force_move(back)](auto&&... rest_args) mutable { + static_assert( + std::is_constructible_v< + disconnect_packet, + decltype(rest_args)... + >, + "disconnect_packet is not constructible" ); + try { + return impl_type::async_disconnect( + impl_, + error_code{}, + disconnect_packet{std::forward(rest_args)...}, + force_move(back) + ); + } + catch (system_error const& se) { + return impl_type::async_disconnect( + impl_, + se.code(), + std::nullopt, + force_move(back) + ); + } } - } - ); + ); + }(std::forward(args)...); } } diff --git a/include/async_mqtt/asio_bind/impl/client_publish.hpp b/include/async_mqtt/asio_bind/impl/client_publish.hpp index 0201a50e7..29b7d720d 100644 --- a/include/async_mqtt/asio_bind/impl/client_publish.hpp +++ b/include/async_mqtt/asio_bind/impl/client_publish.hpp @@ -87,37 +87,39 @@ client::async_publish(Args&&... args) { } } else { - auto all = hana::tuple(std::forward(args)...); - auto back = hana::back(all); - auto rest = hana::drop_back(all, hana::size_c<1>); - return hana::unpack( - std::move(rest), - [&](auto&&... rest_args) { - static_assert( - std::is_constructible_v< - publish_packet, - decltype(rest_args)... - >, - "publish_packet is not constructible" - ); - try { - return impl_type::async_publish( - impl_, - error_code{}, - publish_packet{std::forward(rest_args)...}, - force_move(back) - ); - } - catch (system_error const& se) { - return impl_type::async_publish( - impl_, - se.code(), - std::nullopt, - force_move(back) + return [this](auto&&... all_args) { + auto all = hana::make_tuple(std::forward(all_args)...); + constexpr auto N = sizeof...(all_args); + auto back = hana::at_c(force_move(all)); + return hana::unpack( + hana::drop_back(force_move(all), hana::size_c<1>), + [this, back = force_move(back)](auto&&... rest_args) mutable { + static_assert( + std::is_constructible_v< + publish_packet, + decltype(rest_args)... + >, + "publish_packet is not constructible" ); + try { + return impl_type::async_publish( + impl_, + error_code{}, + publish_packet{std::forward(rest_args)...}, + force_move(back) + ); + } + catch (system_error const& se) { + return impl_type::async_publish( + impl_, + se.code(), + std::nullopt, + force_move(back) + ); + } } - } - ); + ); + }(std::forward(args)...); } } diff --git a/include/async_mqtt/asio_bind/impl/client_start.hpp b/include/async_mqtt/asio_bind/impl/client_start.hpp index c47b406c0..7ce22a284 100644 --- a/include/async_mqtt/asio_bind/impl/client_start.hpp +++ b/include/async_mqtt/asio_bind/impl/client_start.hpp @@ -89,39 +89,41 @@ client::async_start(Args&&... args) { } } else { - auto all = hana::tuple(std::forward(args)...); - auto back = hana::back(all); - auto rest = hana::drop_back(all, hana::size_c<1>); - return hana::unpack( - std::move(rest), - [&](auto&&... rest_args) { - static_assert( - std::is_constructible_v< - connect_packet, - decltype(rest_args)... - >, - "connect_packet is not constructible" - ); - try { - return impl_type::async_start( - impl_, - error_code{}, - connect_packet{ - std::forward>(rest_args)... - }, - force_move(back) - ); - } - catch (system_error const& se) { - return impl_type::async_start( - impl_, - se.code(), - std::nullopt, - force_move(back) + return [this](auto&&... all_args) { + auto all = hana::make_tuple(std::forward(all_args)...); + constexpr auto N = sizeof...(all_args); + auto back = hana::at_c(force_move(all)); + return hana::unpack( + hana::drop_back(force_move(all), hana::size_c<1>), + [this, back = force_move(back)](auto&&... rest_args) mutable { + static_assert( + std::is_constructible_v< + connect_packet, + decltype(rest_args)... + >, + "connect_packet is not constructible" ); + try { + return impl_type::async_start( + impl_, + error_code{}, + connect_packet{ + std::forward>(rest_args)... + }, + force_move(back) + ); + } + catch (system_error const& se) { + return impl_type::async_start( + impl_, + se.code(), + std::nullopt, + force_move(back) + ); + } } - } - ); + ); + }(std::forward(args)...); } } diff --git a/include/async_mqtt/asio_bind/impl/client_subscribe.hpp b/include/async_mqtt/asio_bind/impl/client_subscribe.hpp index f5eef75eb..16fb33697 100644 --- a/include/async_mqtt/asio_bind/impl/client_subscribe.hpp +++ b/include/async_mqtt/asio_bind/impl/client_subscribe.hpp @@ -87,37 +87,39 @@ client::async_subscribe(Args&&... args) { } } else { - auto all = hana::tuple(std::forward(args)...); - auto back = hana::back(all); - auto rest = hana::drop_back(all, hana::size_c<1>); - return hana::unpack( - std::move(rest), - [&](auto&&... rest_args) { - static_assert( - std::is_constructible_v< - subscribe_packet, - decltype(rest_args)... - >, - "subscribe_packet is not constructible" - ); - try { - return impl_type::async_subscribe( - impl_, - error_code{}, - subscribe_packet{std::forward(rest_args)...}, - force_move(back) - ); - } - catch (system_error const& se) { - return impl_type::async_subscribe( - impl_, - se.code(), - std::nullopt, - force_move(back) + return [this](auto&&... all_args) { + auto all = hana::make_tuple(std::forward(all_args)...); + constexpr auto N = sizeof...(all_args); + auto back = hana::at_c(force_move(all)); + return hana::unpack( + hana::drop_back(force_move(all), hana::size_c<1>), + [this, back = force_move(back)](auto&&... rest_args) mutable { + static_assert( + std::is_constructible_v< + subscribe_packet, + decltype(rest_args)... + >, + "subscribe_packet is not constructible" ); + try { + return impl_type::async_subscribe( + impl_, + error_code{}, + subscribe_packet{std::forward(rest_args)...}, + force_move(back) + ); + } + catch (system_error const& se) { + return impl_type::async_subscribe( + impl_, + se.code(), + std::nullopt, + force_move(back) + ); + } } - } - ); + ); + }(std::forward(args)...); } } diff --git a/include/async_mqtt/asio_bind/impl/client_unsubscribe.hpp b/include/async_mqtt/asio_bind/impl/client_unsubscribe.hpp index d82c14200..73f7aed96 100644 --- a/include/async_mqtt/asio_bind/impl/client_unsubscribe.hpp +++ b/include/async_mqtt/asio_bind/impl/client_unsubscribe.hpp @@ -87,37 +87,39 @@ client::async_unsubscribe(Args&&... args) { } } else { - auto all = hana::tuple(std::forward(args)...); - auto back = hana::back(all); - auto rest = hana::drop_back(all, hana::size_c<1>); - return hana::unpack( - std::move(rest), - [&](auto&&... rest_args) { - static_assert( - std::is_constructible_v< - unsubscribe_packet, - decltype(rest_args)... - >, - "unsubscribe_packet is not constructible" - ); - try { - return impl_type::async_unsubscribe( - impl_, - error_code{}, - unsubscribe_packet{std::forward(rest_args)...}, - force_move(back) - ); - } - catch (system_error const& se) { - return impl_type::async_unsubscribe( - impl_, - se.code(), - std::nullopt, - force_move(back) + return [this](auto&&... all_args) { + auto all = hana::make_tuple(std::forward(all_args)...); + constexpr auto N = sizeof...(all_args); + auto back = hana::at_c(force_move(all)); + return hana::unpack( + hana::drop_back(force_move(all), hana::size_c<1>), + [this, back = force_move(back)](auto&&... rest_args) mutable { + static_assert( + std::is_constructible_v< + unsubscribe_packet, + decltype(rest_args)... + >, + "unsubscribe_packet is not constructible" ); + try { + return impl_type::async_unsubscribe( + impl_, + error_code{}, + unsubscribe_packet{std::forward(rest_args)...}, + force_move(back) + ); + } + catch (system_error const& se) { + return impl_type::async_unsubscribe( + impl_, + se.code(), + std::nullopt, + force_move(back) + ); + } } - } - ); + ); + }(std::forward(args)...); } } diff --git a/include/async_mqtt/asio_bind/impl/endpoint_underlying_handshake.hpp b/include/async_mqtt/asio_bind/impl/endpoint_underlying_handshake.hpp index 116a1143d..78d4eb564 100644 --- a/include/async_mqtt/asio_bind/impl/endpoint_underlying_handshake.hpp +++ b/include/async_mqtt/asio_bind/impl/endpoint_underlying_handshake.hpp @@ -145,9 +145,6 @@ basic_endpoint::async_underlying_handshake( Args&&... args ) { BOOST_ASSERT(impl_); - auto all = hana::tuple(std::forward(args)...); - auto back = hana::back(all); - auto rest = hana::drop_back(all, hana::size_c<1>); if constexpr( detail::is_customize_handshake_callable< @@ -155,13 +152,18 @@ basic_endpoint::async_underlying_handshake( Args... >::value ) { - return impl_type::async_underlying_handshake_impl( - impl_, - force_move(rest), - force_move(back) // token - ); + return [this](auto&&... all_args) { + auto all = hana::make_tuple(std::forward(all_args)...); + constexpr auto N = sizeof...(all_args); + return impl_type::async_underlying_handshake_impl( + impl_, + hana::drop_back(force_move(all), hana::size_c<1>), + hana::at_c(force_move(all)) // token + ); + }(std::forward(args)...); } else { + auto all = hana::tuple(std::forward(args)...); return impl_type::async_underlying_handshake_impl( impl_, force_move(all)