input_sequence.hpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
  2. // (C) Copyright 2003-2007 Jonathan Turkanis
  3. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
  5. // See http://www.boost.org/libs/iostreams for documentation.
  6. #ifndef BOOST_IOSTREAMS_INPUT_SEQUENCE_HPP_INCLUDED
  7. #define BOOST_IOSTREAMS_INPUT_SEQUENCE_HPP_INCLUDED
  8. #if defined(_MSC_VER)
  9. # pragma once
  10. #endif
  11. #include <utility> // pair.
  12. #include <boost/config.hpp> // DEDUCED_TYPENAME, MSVC.
  13. #include <boost/detail/workaround.hpp>
  14. #include <boost/iostreams/detail/wrap_unwrap.hpp>
  15. #include <boost/iostreams/operations_fwd.hpp> // is_custom
  16. #include <boost/iostreams/traits.hpp>
  17. #include <boost/mpl/if.hpp>
  18. // Must come last.
  19. #include <boost/iostreams/detail/config/disable_warnings.hpp>
  20. namespace boost { namespace iostreams {
  21. namespace detail {
  22. template<typename T>
  23. struct input_sequence_impl;
  24. } // End namespace detail.
  25. template<typename T>
  26. inline std::pair<
  27. BOOST_DEDUCED_TYPENAME char_type_of<T>::type*,
  28. BOOST_DEDUCED_TYPENAME char_type_of<T>::type*
  29. >
  30. input_sequence(T& t)
  31. { return detail::input_sequence_impl<T>::input_sequence(t); }
  32. namespace detail {
  33. //------------------Definition of direct_impl-------------------------------//
  34. template<typename T>
  35. struct input_sequence_impl
  36. : mpl::if_<
  37. detail::is_custom<T>,
  38. operations<T>,
  39. input_sequence_impl<direct_tag>
  40. >::type
  41. { };
  42. template<>
  43. struct input_sequence_impl<direct_tag> {
  44. template<typename U>
  45. static std::pair<
  46. BOOST_DEDUCED_TYPENAME char_type_of<U>::type*,
  47. BOOST_DEDUCED_TYPENAME char_type_of<U>::type*
  48. >
  49. input_sequence(U& u) { return u.input_sequence(); }
  50. };
  51. } // End namespace detail.
  52. } } // End namespaces iostreams, boost.
  53. #include <boost/iostreams/detail/config/enable_warnings.hpp>
  54. #endif // #ifndef BOOST_IOSTREAMS_INPUT_SEQUENCE_HPP_INCLUDED