rebind_executor.hpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //
  2. // Copyright (c) 2023-2025 Ivica Siladic, Bruno Iljazovic, Korina Simicevic
  3. //
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // (See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. #ifndef BOOST_MQTT5_REBIND_EXECUTOR_HPP
  8. #define BOOST_MQTT5_REBIND_EXECUTOR_HPP
  9. namespace boost::asio::ssl {
  10. // forward declare to preserve optional OpenSSL dependency
  11. template <typename Stream>
  12. class stream;
  13. } // end namespace boost::asio::ssl
  14. // forward declare to avoid Beast dependency
  15. namespace boost::beast::websocket {
  16. template <typename Stream, bool deflate_supported>
  17. class stream;
  18. }// end namespace boost::beast::websocket
  19. namespace boost::mqtt5::detail {
  20. namespace asio = boost::asio;
  21. template <typename Stream, typename Executor>
  22. struct rebind_executor {
  23. using other = typename Stream::template rebind_executor<Executor>::other;
  24. };
  25. // asio::ssl::stream does not define a rebind_executor member type
  26. template <typename Stream, typename Executor>
  27. struct rebind_executor<asio::ssl::stream<Stream>, Executor> {
  28. using other = typename asio::ssl::stream<
  29. typename rebind_executor<Stream, Executor>::other
  30. >;
  31. };
  32. template <typename Stream, bool deflate_supported, typename Executor>
  33. struct rebind_executor<
  34. boost::beast::websocket::stream<asio::ssl::stream<Stream>, deflate_supported>,
  35. Executor
  36. > {
  37. using other = typename boost::beast::websocket::stream<
  38. asio::ssl::stream<typename rebind_executor<Stream, Executor>::other>,
  39. deflate_supported
  40. >;
  41. };
  42. } // end namespace boost::mqtt5::detail
  43. #endif // !BOOST_MQTT5_REBIND_EXECUTOR_HPP