Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

function_output_iterator.hpp

Go to the documentation of this file.
00001 // (C) Copyright Jeremy Siek 2001.
00002 // Distributed under the Boost Software License, Version 1.0. (See
00003 // accompanying file LICENSE_1_0.txt or copy at
00004 // http://www.boost.org/LICENSE_1_0.txt)
00005 
00006 // Revision History:
00007 
00008 // 27 Feb 2001   Jeremy Siek
00009 //      Initial checkin.
00010 
00011 #ifndef BOOST_FUNCTION_OUTPUT_ITERATOR_HPP
00012 #define BOOST_FUNCTION_OUTPUT_ITERATOR_HPP
00013 
00014 #include <iterator>
00015 
00016 namespace boost {
00017 
00018   template <class UnaryFunction>
00019   class function_output_iterator {
00020     typedef function_output_iterator self;
00021   public:
00022     typedef std::output_iterator_tag iterator_category;
00023     typedef void                value_type;
00024     typedef void                difference_type;
00025     typedef void                pointer;
00026     typedef void                reference;
00027 
00028     explicit function_output_iterator() {}
00029 
00030     explicit function_output_iterator(const UnaryFunction& f)
00031       : m_f(f) {}
00032 
00033     struct output_proxy {
00034       output_proxy(UnaryFunction& f) : m_f(f) { }
00035       template <class T> output_proxy& operator=(const T& value) {
00036         m_f(value); 
00037         return *this; 
00038       }
00039       UnaryFunction& m_f;
00040     };
00041     output_proxy operator*() { return output_proxy(m_f); }
00042     self& operator++() { return *this; } 
00043     self& operator++(int) { return *this; }
00044   private:
00045     UnaryFunction m_f;
00046   };
00047 
00048   template <class UnaryFunction>
00049   inline function_output_iterator<UnaryFunction>
00050   make_function_output_iterator(const UnaryFunction& f = UnaryFunction()) {
00051     return function_output_iterator<UnaryFunction>(f);
00052   }
00053 
00054 } // namespace boost
00055 
00056 #endif // BOOST_FUNCTION_OUTPUT_ITERATOR_HPP

Generated on Wed May 25 14:39:16 2005 for Arak by doxygen 1.3.6