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