Skip to content


Subversion checkout URL

You can clone with
Download ZIP


std::copying tpie::array iterators should use memmove when possible #31

Mortal opened this Issue · 2 comments

1 participant


Right now, it does not seem that using std::copy with tpie::array on POD types lead to a memmove call when this is the case for std::vector. However, tpie::array and std::vector are similar enough that one would expect this to be the case.


In libstdc++, bits/stl_algobase.h, there is an __Niter_base struct whose job it is to return the base of an iterator (the raw pointer) when the iterator is a __normal_iterator. It seems that if we derive tpie::array's iterator type from std::iterator we will get this bonus.


I've done some more digging, and concerning the libstdc++ implementation and optimizing std::copy, I've found:

std::vector has an iterator typedef that is an alias of __normal_iterator. A __normal_iterator has a public member base() which returns the base (in the case of vector, a T pointer). std::copy and friends optimize for __normal_iterators by using the base() member - in all other cases, no optimization is done by std::copy.

In other words, if we used std::gnu_cxx::__normal_iterator as our tpie::array iterator, we would get the memmove optimization, but this is obviously not portable and not what we want.

However, we could define a template specialization of std::copy for tpie::array::iterators when T is a pod type. Is this perhaps what we should do?

@Mortal Mortal referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@Mortal Mortal was assigned
@Mortal Mortal closed this in 2f79196
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.