On 6/23/13 4:04 AM, monarch_dodra wrote:
R range;
auto r3 = findSplit(range);
void do_it(r3[0]);
void do_it(r3[1]);
void do_it(r3[2]);

This will actually instantiate 2 different do_it functions.

Yah, this is a good summary. If individual iterators are accessible, findSplit can return three ranges of the same type. Otherwise, generally findSplit must return ranges of distinct types.

Note, however, that if the initial range is strictly forward, the three resulting range may not have the same type as the initial range. As a simple example, findSplit over a singly-linked list cannot return three singly-linked lists.

(I don't think template bloat is the main problem here, instead a sort of matter of principles.)

Again, we can make things work by introducing a primitive for bidirectional ranges:

R before(R r1, R r2);

Assuming r2 is reachable from r1, returns the portion of r1 that lies before r2. (Definition: a range r2 is reachable from another range r1 if calling r1.popFront() repeatedly will at some point make r1.front and r2.front refer to the same value.)


Andrei

Reply via email to