[range] contiguous iterators

Hi everyone, is there any way to generically determine at compiletime whether an iterator or a boost range refers to contiguous memory? i.e. &*(it+1) == (&*it)+1 some type trait like is_contiguous<T *>::value == true is_contiguous<vector<T>::iterator>::value == true is_contiguous<std::list<T>::iterator>::value == false ?

On Sat, Mar 16, 2013 at 7:42 AM, Stefan Strasser <strasser@uni-bremen.de>wrote:
Hi everyone,
is there any way to generically determine at compiletime whether an iterator or a boost range refers to contiguous memory?
i.e. &*(it+1) == (&*it)+1
some type trait like
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. - Jeff

On Sat, Mar 16, 2013 at 10:42 AM, Stefan Strasser <strasser@uni-bremen.de> wrote:
Hi everyone,
is there any way to generically determine at compiletime whether an iterator or a boost range refers to contiguous memory?
i.e. &*(it+1) == (&*it)+1
some type trait like
is_contiguous<T *>::value == true is_contiguous<vector<T>::iterator>::value == true is_contiguous<std::list<T>::iterator>::value == false
?
Hi Stefan, I needed this functionality for Boost.Compute in order to determine if a region of memory could be copied directly to the GPU or if an intermediate std::vector was required. It works just like your example except I used the name is_contiguous_iterator instead. The implementation is here: https://github.com/kylelutz/compute/blob/master/include/boost/compute/detail... Cheers, Kyle
participants (3)
-
Jeffrey Lee Hellrung, Jr.
-
Kyle Lutz
-
Stefan Strasser