is_read_buffered.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // is_read_buffered.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. #ifndef BOOST_ASIO_IS_READ_BUFFERED_HPP
  11. #define BOOST_ASIO_IS_READ_BUFFERED_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include <boost/asio/detail/config.hpp>
  16. #include <boost/asio/buffered_read_stream_fwd.hpp>
  17. #include <boost/asio/buffered_stream_fwd.hpp>
  18. #include <boost/asio/detail/push_options.hpp>
  19. namespace boost {
  20. namespace asio {
  21. namespace detail {
  22. template <typename Stream>
  23. char is_read_buffered_helper(buffered_stream<Stream>* s);
  24. template <typename Stream>
  25. char is_read_buffered_helper(buffered_read_stream<Stream>* s);
  26. struct is_read_buffered_big_type { char data[10]; };
  27. is_read_buffered_big_type is_read_buffered_helper(...);
  28. } // namespace detail
  29. /// The is_read_buffered class is a traits class that may be used to determine
  30. /// whether a stream type supports buffering of read data.
  31. template <typename Stream>
  32. class is_read_buffered
  33. {
  34. public:
  35. #if defined(GENERATING_DOCUMENTATION)
  36. /// The value member is true only if the Stream type supports buffering of
  37. /// read data.
  38. static const bool value;
  39. #else
  40. BOOST_ASIO_STATIC_CONSTANT(bool,
  41. value = sizeof(detail::is_read_buffered_helper((Stream*)0)) == 1);
  42. #endif
  43. };
  44. } // namespace asio
  45. } // namespace boost
  46. #include <boost/asio/detail/pop_options.hpp>
  47. #endif // BOOST_ASIO_IS_READ_BUFFERED_HPP