Line | |
---|
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)
|
---|
5 |
|
---|
6 | // Revision History:
|
---|
7 |
|
---|
8 | // 27 Feb 2001 Jeremy Siek
|
---|
9 | // Initial checkin.
|
---|
10 |
|
---|
11 | #ifndef BOOST_FUNCTION_OUTPUT_ITERATOR_HPP
|
---|
12 | #define BOOST_FUNCTION_OUTPUT_ITERATOR_HPP
|
---|
13 |
|
---|
14 | #include <iterator>
|
---|
15 |
|
---|
16 | namespace boost {
|
---|
17 |
|
---|
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;
|
---|
27 |
|
---|
28 | explicit function_output_iterator() {}
|
---|
29 |
|
---|
30 | explicit function_output_iterator(const UnaryFunction& f)
|
---|
31 | : m_f(f) {}
|
---|
32 |
|
---|
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;
|
---|
38 | }
|
---|
39 | UnaryFunction& m_f;
|
---|
40 | };
|
---|
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;
|
---|
46 | };
|
---|
47 |
|
---|
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);
|
---|
52 | }
|
---|
53 |
|
---|
54 | } // namespace boost
|
---|
55 |
|
---|
56 | #endif // BOOST_FUNCTION_OUTPUT_ITERATOR_HPP
|
---|
Note: See
TracBrowser
for help on using the repository browser.