lazy.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright (c) 2001-2011 Hartmut Kaiser
  2. //
  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. #include <boost/config/warning_disable.hpp>
  6. #include <boost/detail/lightweight_test.hpp>
  7. #include <boost/spirit/include/karma_char.hpp>
  8. #include <boost/spirit/include/karma_string.hpp>
  9. #include <boost/spirit/include/karma_numeric.hpp>
  10. #include <boost/spirit/include/karma_auxiliary.hpp>
  11. #include <boost/spirit/include/karma_action.hpp>
  12. // #include <boost/spirit/include/karma_nonterminal.hpp>
  13. // #include <boost/spirit/include/karma_operator.hpp>
  14. #include <boost/spirit/include/support_argument.hpp>
  15. #include <boost/spirit/include/phoenix_core.hpp>
  16. #include <boost/spirit/include/phoenix_operator.hpp>
  17. #include <iostream>
  18. #include "test.hpp"
  19. int
  20. main()
  21. {
  22. namespace karma = boost::spirit::karma;
  23. using spirit_test::test;
  24. using namespace boost::spirit;
  25. using namespace boost::spirit::karma;
  26. namespace phx = boost::phoenix;
  27. {
  28. BOOST_TEST(test("123", karma::lazy(phx::val(int_)), 123));
  29. }
  30. {
  31. int result = 123;
  32. BOOST_TEST(test("123", karma::lazy(phx::val(int_))[_1 = phx::ref(result)]));
  33. }
  34. // {
  35. // typedef spirit_test::output_iterator<char>::type outiter_type;
  36. // rule<outiter_type, void(std::string)> r;
  37. //
  38. // r = char_('<') << karma::lazy(_r1) << '>' << "</" << karma::lazy(_r1) << '>';
  39. //
  40. // std::string tag("tag"), foo("foo");
  41. // BOOST_TEST(test("<tag></tag>", r (phx::ref(tag))));
  42. // BOOST_TEST(!test("<foo></bar>", r (phx::ref(foo))));
  43. // }
  44. return boost::report_errors();
  45. }