
Le 07/07/2010 17:36, John Dlugosz a écrit :
After pondering something like join(join(R1,R2),R3), I realized that the whole idea, while it would make functional programming guys smile, is inefficient. Iterating the joined range and copying one element at a time, with overhead to look for boundaries, will prevent the container's optimized push_back from being called with a range of contiguous memory of trivial items.
So, I really want something that will call that form for the ranges. Now I'm thinking of a metaprogram like used for matrix math, to collect the N-ary concats and then apply them when the final thing is converted to a vector.
Really, I'd like an "Assign" that uses such techniques instead of throwing everything into a deque and then copying it.
The constructor of vector and its assign member function are already optimized to exploit random access iterators. Note however that a joined range of random access ranges doesn't know that every joined range is the same size, so its random access features are a bit slow.