io.hpp 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*=============================================================================
  2. Copyright (c) 2001-2007 Joel de Guzman
  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. ==============================================================================*/
  6. #ifndef PHOENIX_OPERATOR_IO_HPP
  7. #define PHOENIX_OPERATOR_IO_HPP
  8. #include <boost/spirit/home/phoenix/operator/detail/io.hpp>
  9. namespace boost { namespace phoenix
  10. {
  11. ///////////////////////////////////////////////////////////////////////////////
  12. //
  13. // overloads for std::basic_ostream and std::basic_istream
  14. //
  15. ///////////////////////////////////////////////////////////////////////////////
  16. template <typename T0, typename T1>
  17. inline typename detail::enable_if_ostream<T0, T1>::type
  18. operator<<(T0& a0, actor<T1> const& a1)
  19. {
  20. return compose<shift_left_eval>(phoenix::ref(a0), a1);
  21. }
  22. template <typename T0, typename T1>
  23. inline typename detail::enable_if_istream<T0, T1>::type
  24. operator>>(T0& a0, actor<T1> const& a1)
  25. {
  26. return compose<shift_right_eval>(phoenix::ref(a0), a1);
  27. }
  28. // resolve ambiguities with fusion.
  29. template <typename T1>
  30. inline typename detail::enable_if_ostream<std::ostream, T1>::type
  31. operator<<(std::ostream& a0, actor<T1> const& a1)
  32. {
  33. return compose<shift_left_eval>(phoenix::ref(a0), a1);
  34. }
  35. template <typename T1>
  36. inline typename detail::enable_if_istream<std::istream, T1>::type
  37. operator>>(std::istream& a0, actor<T1> const& a1)
  38. {
  39. return compose<shift_right_eval>(phoenix::ref(a0), a1);
  40. }
  41. ///////////////////////////////////////////////////////////////////////////////
  42. //
  43. // overloads for I/O manipulators.
  44. //
  45. ///////////////////////////////////////////////////////////////////////////////
  46. template <typename T0>
  47. inline actor<typename as_composite<
  48. shift_left_eval, actor<T0>, detail::omanip_type>::type>
  49. operator<<(actor<T0> const& a0, detail::omanip_type a1)
  50. {
  51. return compose<shift_left_eval>(a0, a1);
  52. }
  53. template <typename T0>
  54. inline actor<typename as_composite<
  55. shift_left_eval, actor<T0>, detail::iomanip_type>::type>
  56. operator<<(actor<T0> const& a0, detail::iomanip_type a1)
  57. {
  58. return compose<shift_left_eval>(a0, a1);
  59. }
  60. template <typename T0>
  61. inline actor<typename as_composite<
  62. shift_right_eval, actor<T0>, detail::imanip_type>::type>
  63. operator>>(actor<T0> const& a0, detail::imanip_type a1)
  64. {
  65. return compose<shift_right_eval>(a0, a1);
  66. }
  67. template <typename T0>
  68. inline actor<typename as_composite<
  69. shift_right_eval, actor<T0>, detail::iomanip_type>::type>
  70. operator>>(actor<T0> const& a0, detail::iomanip_type a1)
  71. {
  72. return compose<shift_right_eval>(a0, a1);
  73. }
  74. }}
  75. #endif