Boost logo

Boost Users :

Subject: [Boost-users] [iterator] - does there exist an opposite of Function Output Iterator?
From: Michael Fawcett (michael.fawcett_at_[hidden])
Date: 2009-02-05 12:21:51


http://www.boost.org/doc/libs/1_37_0/libs/iterator/doc/function_output_iterator.html

Shows a unary function being adapted as an OutputIterator. Does Boost
have something that does the opposite, i.e. takes an OutputIterator
and adapts it as a unary function object?

In my own code I currently have:

template <typename OutputIterator>
struct output_iterator_function
{
        explicit output_iterator_function(OutputIterator i) : iter(i) { }

        template <typename T>
        void operator()(const T &v)
        {
                *iter++ = v;
        }

        OutputIterator iter;
};

template <typename OutputIterator>
output_iterator_function<OutputIterator>
make_output_iterator_function(OutputIterator i)
{
        return output_iterator_function<OutputIterator>(i);
}

If this doesn't already exist in Boost.Iterator, it seems like it
would nicely complement the already existing function_output_iterator.

--Michael Fawcett


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net