Boost logo

Boost :

Subject: Re: [boost] [range][iterator] contiguous iterators
From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2013-03-19 06:29:46


On 19-03-2013 11:03, Stefan Strasser wrote:

> I'd also like to suggest another addition to Boost.Range:
> a RangeOutputIterator, i.e. an OutputIterator that doesn't only accept
> single values, but assignment of ranges:
>
> template<class RangeOutputIterator> ... (...RangeOutputIterator out){
> *out=range;
>
>
> where range can be any Boost.Range. You can find an implementation of
> this concept here, in the form of an back insert iterator that can
> insert entire ranges into a vector: http://pastebin.com/9M5rPDh9
>
> Using these two things together can make generic algorithms as efficient
> as is possible, e.g. if the container that is being written to is a
> vector and the value type is a POD, there's one call to std::memcpy.
> think e.g. about file or database operations like
> database.get(1024*1024,out);
>
> This is in my "namespace detail" right now and I'd be willing to help
> make it public and document it.

Have you considered

http://www.boost.org/doc/libs/1_53_0/libs/range/doc/html/range/reference/algorithms/new.html

?

E.g. using

    boost::push_back( my_container, my_range )

should be optimally efficient and more direct than using an output range.

-Thorsten


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