fix doc example typo
[boost.git] / boost / function_output_iterator.hpp
blob9720f3f3d19317f72897c1e80530d0fcdb626db0
1 // (C) Copyright Jeremy Siek 2001.
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 #ifndef BOOST_FUNCTION_OUTPUT_ITERATOR_HPP
12 #define BOOST_FUNCTION_OUTPUT_ITERATOR_HPP
14 #include <iterator>
16 namespace boost {
18 template <class UnaryFunction>
19 class function_output_iterator {
20 typedef function_output_iterator self;
21 public:
22 typedef std::output_iterator_tag iterator_category;
23 typedef void value_type;
24 typedef void difference_type;
25 typedef void pointer;
26 typedef void reference;
28 explicit function_output_iterator() {}
30 explicit function_output_iterator(const UnaryFunction& f)
31 : m_f(f) {}
33 struct output_proxy {
34 output_proxy(UnaryFunction& f) : m_f(f) { }
35 template <class T> output_proxy& operator=(const T& value) {
36 m_f(value);
37 return *this;
39 UnaryFunction& m_f;
41 output_proxy operator*() { return output_proxy(m_f); }
42 self& operator++() { return *this; }
43 self& operator++(int) { return *this; }
44 private:
45 UnaryFunction m_f;
48 template <class UnaryFunction>
49 inline function_output_iterator<UnaryFunction>
50 make_function_output_iterator(const UnaryFunction& f = UnaryFunction()) {
51 return function_output_iterator<UnaryFunction>(f);
54 } // namespace boost
56 #endif // BOOST_FUNCTION_OUTPUT_ITERATOR_HPP