io_tests.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. #include <iostream>
  7. #include <vector>
  8. #include <algorithm>
  9. #include <sstream>
  10. #include <string>
  11. #include <algorithm>
  12. #include <boost/detail/lightweight_test.hpp>
  13. #include <boost/phoenix/core.hpp>
  14. #include <boost/phoenix/operator.hpp>
  15. namespace phoenix = boost::phoenix;
  16. int
  17. main()
  18. {
  19. using phoenix::val;
  20. using phoenix::arg_names::arg1;
  21. using phoenix::arg_names::arg2;
  22. using std::cout;
  23. using std::endl;
  24. using std::hex;
  25. using std::for_each;
  26. using std::string;
  27. using std::stringstream;
  28. using std::vector;
  29. int i100 = 100;
  30. string hello = "hello";
  31. const char* world = " world";
  32. int init[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
  33. vector<int> v(init, init+10);
  34. char const* msg = "cout assert\n";
  35. (cout << arg1)(msg);
  36. (cout << arg1 << endl)(hello);
  37. (arg1 << hex)(cout);
  38. (cout << val(hello))();
  39. (cout << val(hello) << world << ", you da man!\n")();
  40. for_each(v.begin(), v.end(), cout << arg1 << ',');
  41. (cout << arg1 + 1)(i100);
  42. (cout << arg1 << "this is it, shukz:" << hex << arg2 << endl << endl)(msg, i100);
  43. int in;
  44. int out = 12345;
  45. stringstream sstr;
  46. (sstr << arg1)(out);
  47. (sstr >> arg1)(in);
  48. BOOST_TEST(in == out);
  49. return boost::report_errors();
  50. }