From f27fd095f70783969025d508c41140cc54d5ff3f Mon Sep 17 00:00:00 2001 From: Jeremy Siek Date: Tue, 27 Feb 2001 05:49:55 +0000 Subject: [PATCH] new file, part of the iterator adaptors library [SVN r9350] --- include/boost/function_output_iterator.hpp | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 include/boost/function_output_iterator.hpp diff --git a/include/boost/function_output_iterator.hpp b/include/boost/function_output_iterator.hpp new file mode 100644 index 0000000..764c118 --- /dev/null +++ b/include/boost/function_output_iterator.hpp @@ -0,0 +1,55 @@ +// (C) Copyright Jeremy Siek 2001. Permission to copy, use, modify, +// sell and distribute this software is granted provided this +// copyright notice appears in all copies. This software is provided +// "as is" without express or implied warranty, and with no claim as +// to its suitability for any purpose. + +// Revision History: + +// 27 Feb 2001 Jeremy Siek +// Initial checkin. + +#ifndef BOOST_FUNCTION_OUTPUT_ITERATOR_HPP +#define BOOST_FUNCTION_OUTPUT_ITERATOR_HPP + +#include + +namespace boost { + + template + class function_output_iterator { + typedef function_output_iterator self; + public: + typedef std::output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + + explicit function_output_iterator(const UnaryFunction& f = UnaryFunction()) + : m_f(f) {} + + struct output_proxy { + output_proxy(UnaryFunction& f) : m_f(f) { } + template output_proxy& operator=(const T& value) { + m_f(value); + return *this; + } + UnaryFunction& m_f; + }; + output_proxy operator*() { return output_proxy(m_f); } + self& operator++() { return *this; } + self& operator++(int) { return *this; } + private: + UnaryFunction m_f; + }; + + template + inline function_output_iterator + make_function_output_iterator(const UnaryFunction& f = UnaryFunction()) { + return function_output_iterator(f); + } + +} // namespace boost + +#endif // BOOST_FUNCTION_OUTPUT_ITERATOR_HPP