$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] [range][iterator] contiguous iterators
From: Stefan Strasser (strasser_at_[hidden])
Date: 2013-03-19 06:03:47
From [boost-users]:
Am 18.03.2013 16:06, schrieb Jeffrey Lee Hellrung, Jr.:
> On Sat, Mar 16, 2013 at 7:42 AM, Stefan Strasser <strasser_at_[hidden]
> is there any way to generically determine at compiletime whether an
> iterator or a boost range refers to contiguous memory?
>
> is_contiguous<T *>::value == true
> is_contiguous<vector<T>::iterator>::value == true
> is_contiguous<std::list<T>::iterator>::value == false
> AFAIK, not presently, but this has been discussed quite a bit in several
> past threads on the Boost developers list.
Then I'd like to suggest this again to the maintainers of Boost.Iterator
and Boost.Range.
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.
Stefan