Improve vacpp support.
[boost.git] / boost / libs / iterator / example / func_output_iter_example.cpp
blob9c06319885c6aba1403310b72b5f36652b3f82d4
1 // (C) Copyright Jeremy Siek 2001-2004.
2 // Distributed under the Boost Software License, Version 1.0. (See
3 // accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
6 // Revision History:
8 // 27 Feb 2001 Jeremy Siek
9 // Initial checkin.
11 #include <iostream>
12 #include <string>
13 #include <vector>
15 #include <boost/function_output_iterator.hpp>
17 struct string_appender
19 string_appender(std::string& s)
20 : m_str(&s)
23 void operator()(const std::string& x) const
25 *m_str += x;
28 std::string* m_str;
31 int main(int, char*[])
33 std::vector<std::string> x;
34 x.push_back("hello");
35 x.push_back(" ");
36 x.push_back("world");
37 x.push_back("!");
39 std::string s = "";
40 std::copy(x.begin(), x.end(),
41 boost::make_function_output_iterator(string_appender(s)));
43 std::cout << s << std::endl;
45 return 0;