io.hpp 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*==============================================================================
  2. Copyright (c) 2001-2010 Joel de Guzman
  3. Copyright (c) 2010 Thomas Heller
  4. Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. ==============================================================================*/
  7. #ifndef BOOST_PHOENIX_OPERATOR_IO_HPP
  8. #define BOOST_PHOENIX_OPERATOR_IO_HPP
  9. #include <iosfwd>
  10. #include <boost/phoenix/core/limits.hpp>
  11. #include <boost/fusion/sequence/intrinsic/at.hpp>
  12. #include <boost/phoenix/core/domain.hpp>
  13. #include <boost/proto/make_expr.hpp>
  14. #include <boost/proto/tags.hpp>
  15. #include <boost/proto/operators.hpp>
  16. namespace boost { namespace phoenix
  17. {
  18. namespace detail
  19. {
  20. typedef std::ios_base& (*iomanip_type)(std::ios_base&);
  21. typedef std::istream& (*imanip_type)(std::istream&);
  22. typedef std::ostream& (*omanip_type)(std::ostream&);
  23. }
  24. /////////////////////////////////////////////////////////////////////////////
  25. //
  26. // overloads for I/O manipulators.
  27. //
  28. /////////////////////////////////////////////////////////////////////////////
  29. template <typename Expr>
  30. inline
  31. typename proto::result_of::make_expr<
  32. proto::tag::shift_left
  33. , phoenix_domain
  34. , actor<Expr>
  35. , detail::iomanip_type
  36. >::type const
  37. operator<<(actor<Expr> const& a0, detail::iomanip_type a1)
  38. {
  39. return proto::make_expr<
  40. proto::tag::shift_left, phoenix_domain>(a0, a1);
  41. }
  42. template <typename Expr>
  43. inline
  44. typename proto::result_of::make_expr<
  45. proto::tag::shift_left
  46. , phoenix_domain
  47. , actor<Expr>
  48. , detail::omanip_type
  49. >::type const
  50. operator<<(actor<Expr> const& a0, detail::omanip_type a1)
  51. {
  52. return proto::make_expr<
  53. proto::tag::shift_left, phoenix_domain>(a0, a1);
  54. }
  55. template <typename Expr>
  56. inline
  57. typename proto::result_of::make_expr<
  58. proto::tag::shift_right
  59. , phoenix_domain
  60. , actor<Expr>
  61. , detail::iomanip_type
  62. >::type const
  63. operator>>(actor<Expr> const& a0, detail::iomanip_type a1)
  64. {
  65. return proto::make_expr<
  66. proto::tag::shift_right, phoenix_domain>(a0, a1);
  67. }
  68. template <typename Expr>
  69. inline
  70. typename proto::result_of::make_expr<
  71. proto::tag::shift_right
  72. , phoenix_domain
  73. , actor<Expr>
  74. , detail::imanip_type
  75. >::type const
  76. operator>>(actor<Expr> const& a0, detail::imanip_type a1)
  77. {
  78. return proto::make_expr<
  79. proto::tag::shift_right, phoenix_domain>(a0, a1);
  80. }
  81. using proto::exprns_::operator<<;
  82. using proto::exprns_::operator>>;
  83. }}
  84. #endif