PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

C++ Iterator Question

I'm looking for an iterator adapter that will allow me to glue together two (or more) disjoint iterator ranges. Something like this:

Code:

int a1[] = { 1, 3, 5 };
int a2[] = { 2, 4, 6 };

disjoint_iterator it<int>(a1, a1 + 3,
a2, a2 + 3);

sort(it, it + 6);

// results:
// a1 == { 1, 2, 3 }
// a2 == { 4, 5, 6 }


Is there such a thing?
Nothing like that built into the language or standard library.

You will have to right your own. Shouldn't be too hard.