Boost logo

Boost :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2002-10-21 01:01:17


Dan Nuffer wrote:
> As the author of multi_pass, I had originally envisioned submitting
> it separate from spirit. But, one day I realized that I couldn't
> think of a use for it outside of spirit. Maybe I'm just not
> imaginitive enough! But, I personally never had the need to convert
> an input iterator into a forward iterator, other than with spirit.

Here is an easy use case - one wants to know how many elements are in the
input sequence _before_ the actual processing happens, even if at the cost
of additional iteration through the sequence:

    template< typename Iterator >
    void do_input(Iterator first, Iterator last)
    {{
        multi_pass<Iterator> first(first);
        multi_pass<Iterator> last(last);
         
        std::size_t size = std::distance(first, last);
        // using size/fist/last...
    }}

> So, if there is some interest, I'll submit it.

I thought it's being submitted as a part of Spirit anyway ;). IMO it's
definitely should be factored out into a standalone mini-library.

Aleksey


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk