]> git.lyx.org Git - lyx.git/blob - boost/boost/function_output_iterator.hpp
complie fix
[lyx.git] / boost / boost / function_output_iterator.hpp
1 // (C) Copyright Jeremy Siek 2001. Permission to copy, use, modify,
2 // sell and distribute this software is granted provided this
3 // copyright notice appears in all copies. This software is provided
4 // "as is" without express or implied warranty, and with no claim as
5 // to its suitability for any purpose.
6
7 // Revision History:
8
9 // 27 Feb 2001   Jeremy Siek
10 //      Initial checkin.
11
12 #ifndef BOOST_FUNCTION_OUTPUT_ITERATOR_HPP
13 #define BOOST_FUNCTION_OUTPUT_ITERATOR_HPP
14
15 #include <iterator>
16
17 namespace boost {
18
19   template <class UnaryFunction>
20   class function_output_iterator {
21     typedef function_output_iterator self;
22   public:
23     typedef std::output_iterator_tag iterator_category;
24     typedef void                value_type;
25     typedef void                difference_type;
26     typedef void                pointer;
27     typedef void                reference;
28
29     explicit function_output_iterator(const UnaryFunction& f = UnaryFunction())
30       : m_f(f) {}
31
32     struct output_proxy {
33       output_proxy(UnaryFunction& f) : m_f(f) { }
34       template <class T> output_proxy& operator=(const T& value) {
35         m_f(value); 
36         return *this; 
37       }
38       UnaryFunction& m_f;
39     };
40     output_proxy operator*() { return output_proxy(m_f); }
41     self& operator++() { return *this; } 
42     self& operator++(int) { return *this; }
43   private:
44     UnaryFunction m_f;
45   };
46
47   template <class UnaryFunction>
48   inline function_output_iterator<UnaryFunction>
49   make_function_output_iterator(const UnaryFunction& f = UnaryFunction()) {
50     return function_output_iterator<UnaryFunction>(f);
51   }
52
53 } // namespace boost
54
55 #endif // BOOST_FUNCTION_OUTPUT_ITERATOR_HPP