hello_world_redux.cpp 712 B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright (C) 2016-2018 T. Zachary Laine
  2. //
  3. // Distributed under the Boost Software License, Version 1.0. (See
  4. // accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. //[hello_world_redux
  7. #include <boost/yap/algorithm.hpp>
  8. #include <iostream>
  9. template <boost::yap::expr_kind Kind, typename Tuple>
  10. struct stream_expr
  11. {
  12. static const boost::yap::expr_kind kind = Kind;
  13. Tuple elements;
  14. template <typename T>
  15. decltype(auto) operator<< (T && x)
  16. { return boost::yap::value(*this) << std::forward<T &&>(x); }
  17. };
  18. int main ()
  19. {
  20. auto cout = boost::yap::make_terminal<stream_expr>(std::cout);
  21. cout << "Hello" << ',' << " world!\n";
  22. return 0;
  23. }
  24. //]