is_read_buffered.hpp 1.6 KB

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