Boost logo

Boost :

From: brangdon_at_[hidden]
Date: 2001-11-11 16:40:11


In-Reply-To: <4034600A4760D411B8720001031D84FB431086_at_[hidden]>
On Mon, 5 Nov 2001 02:54:50 -0600 Aleksey Gurtovoy (alexy_at_[hidden])
wrote:
> template<typename InputSequence, typename UnaryFunction>
> inline
> UnaryFunction
> for_each(InputSequence const& seq, UnaryFunction const& f)
> {
> return std::for_each(
> boost::begin(seq)
> , boost::end(seq)
> , f
> );
> }

I meant the opposite:

    template <typename iterator, typename functor>
    functor for_each( iterator first, iterator last, functor f ) {
        return for_each( make_sequence( first, last ), f );
    }

This allows the more primitive version of for_each to take advantage of
any methods we add to the sequence object interface. If, as you suggest
elsewhere, a sequence is something which can be modeled by a container, it
can have container-like methods such as empty() and size(). These will
clarify the algorithm's code and perhaps be more efficient.

-- Dave Harris


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