Squashed 'third_party/boostorg/iterator/' content from commit b2adecb
Change-Id: I284a73816f9cc846742923879275b84c6e0c915c
git-subtree-dir: third_party/boostorg/iterator
git-subtree-split: b2adecb951af025698618f19a3c838bd314966dc
diff --git a/example/func_output_iter_example.cpp b/example/func_output_iter_example.cpp
new file mode 100644
index 0000000..9c06319
--- /dev/null
+++ b/example/func_output_iter_example.cpp
@@ -0,0 +1,46 @@
+// (C) Copyright Jeremy Siek 2001-2004.
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// Revision History:
+
+// 27 Feb 2001 Jeremy Siek
+// Initial checkin.
+
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include <boost/function_output_iterator.hpp>
+
+struct string_appender
+{
+ string_appender(std::string& s)
+ : m_str(&s)
+ {}
+
+ void operator()(const std::string& x) const
+ {
+ *m_str += x;
+ }
+
+ std::string* m_str;
+};
+
+int main(int, char*[])
+{
+ std::vector<std::string> x;
+ x.push_back("hello");
+ x.push_back(" ");
+ x.push_back("world");
+ x.push_back("!");
+
+ std::string s = "";
+ std::copy(x.begin(), x.end(),
+ boost::make_function_output_iterator(string_appender(s)));
+
+ std::cout << s << std::endl;
+
+ return 0;
+}