is_read_buffered.hpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //
  2. // is_read_buffered.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2008 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/push_options.hpp>
  16. #include <boost/asio/detail/push_options.hpp>
  17. #include <boost/config.hpp>
  18. #include <boost/asio/detail/pop_options.hpp>
  19. #include <boost/asio/buffered_read_stream_fwd.hpp>
  20. #include <boost/asio/buffered_stream_fwd.hpp>
  21. namespace boost {
  22. namespace asio {
  23. namespace detail {
  24. template <typename Stream>
  25. char is_read_buffered_helper(buffered_stream<Stream>* s);
  26. template <typename Stream>
  27. char is_read_buffered_helper(buffered_read_stream<Stream>* s);
  28. struct is_read_buffered_big_type { char data[10]; };
  29. is_read_buffered_big_type is_read_buffered_helper(...);
  30. } // namespace detail
  31. /// The is_read_buffered class is a traits class that may be used to determine
  32. /// whether a stream type supports buffering of read data.
  33. template <typename Stream>
  34. class is_read_buffered
  35. {
  36. public:
  37. #if defined(GENERATING_DOCUMENTATION)
  38. /// The value member is true only if the Stream type supports buffering of
  39. /// read data.
  40. static const bool value;
  41. #else
  42. BOOST_STATIC_CONSTANT(bool,
  43. value = sizeof(detail::is_read_buffered_helper((Stream*)0)) == 1);
  44. #endif
  45. };
  46. } // namespace asio
  47. } // namespace boost
  48. #include <boost/asio/detail/pop_options.hpp>
  49. #endif // BOOST_ASIO_IS_READ_BUFFERED_HPP