socket_stream.hpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //
  2. // Copyright (c) 2019-2024 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. #ifndef BOOST_MYSQL_DETAIL_SOCKET_STREAM_HPP
  8. #define BOOST_MYSQL_DETAIL_SOCKET_STREAM_HPP
  9. #include <boost/asio/basic_socket.hpp>
  10. #include <boost/asio/basic_stream_socket.hpp>
  11. #include <type_traits>
  12. namespace boost {
  13. namespace mysql {
  14. namespace detail {
  15. template <class T>
  16. struct is_socket : std::false_type
  17. {
  18. };
  19. // typename basic_stream_socket::lowest_layer_type is basic_socket, so we accept basic_socket and
  20. // basic_stream_socket here
  21. template <class Protocol, class Executor>
  22. struct is_socket<asio::basic_socket<Protocol, Executor>> : std::true_type
  23. {
  24. };
  25. template <class Protocol, class Executor>
  26. struct is_socket<asio::basic_stream_socket<Protocol, Executor>> : std::true_type
  27. {
  28. };
  29. template <class T, class = void>
  30. struct is_socket_stream : std::false_type
  31. {
  32. };
  33. template <class T>
  34. struct is_socket_stream<T, typename std::enable_if<is_socket<typename T::lowest_layer_type>::value>::type>
  35. : std::true_type
  36. {
  37. };
  38. } // namespace detail
  39. } // namespace mysql
  40. } // namespace boost
  41. #endif