/Src/Dependencies/Boost/boost/spirit/home/phoenix/operator/detail/io.hpp

http://hadesmem.googlecode.com/ · C++ Header · 78 lines · 62 code · 10 blank · 6 comment · 2 complexity · fb8e4aa29fddc4b8844f8a4b8bf58828 MD5 · raw file

  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_DETAIL_IO_HPP
  7. #define PHOENIX_OPERATOR_DETAIL_IO_HPP
  8. #include <boost/spirit/home/phoenix/operator/bitwise.hpp>
  9. #include <boost/spirit/home/phoenix/core/reference.hpp>
  10. #include <boost/utility/addressof.hpp>
  11. #include <boost/utility/enable_if.hpp>
  12. #include <iostream>
  13. namespace boost { namespace phoenix { namespace detail
  14. {
  15. typedef char(&no)[1];
  16. typedef char(&yes)[2];
  17. template <typename CharType, typename CharTrait>
  18. yes ostream_test(std::basic_ostream<CharType, CharTrait>*);
  19. no ostream_test(...);
  20. template <typename CharType, typename CharTrait>
  21. yes istream_test(std::basic_istream<CharType, CharTrait>*);
  22. no istream_test(...);
  23. template <typename T>
  24. struct is_ostream
  25. {
  26. static T x;
  27. BOOST_STATIC_CONSTANT(bool,
  28. value = sizeof(detail::ostream_test(boost::addressof(x))) == sizeof(yes));
  29. };
  30. template <typename T>
  31. struct is_istream
  32. {
  33. static T x;
  34. BOOST_STATIC_CONSTANT(bool,
  35. value = sizeof(detail::istream_test(boost::addressof(x))) == sizeof(yes));
  36. };
  37. template <typename T0, typename T1>
  38. struct enable_if_ostream :
  39. enable_if<
  40. detail::is_ostream<T0>
  41. , actor<
  42. typename as_composite<
  43. shift_left_eval
  44. , actor<reference<T0> >
  45. , actor<T1>
  46. >::type
  47. >
  48. >
  49. {};
  50. template <typename T0, typename T1>
  51. struct enable_if_istream :
  52. enable_if<
  53. detail::is_istream<T0>
  54. , actor<
  55. typename as_composite<
  56. shift_right_eval
  57. , actor<reference<T0> >
  58. , actor<T1>
  59. >::type
  60. >
  61. >
  62. {};
  63. typedef std::ios_base& (*iomanip_type)(std::ios_base&);
  64. typedef std::istream& (*imanip_type)(std::istream&);
  65. typedef std::ostream& (*omanip_type)(std::ostream&);
  66. }}}
  67. #endif