On 6/23/13 7:39 AM, Andrei Alexandrescu wrote:
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.)
The question is, should we add this primitive? There's discussion on
adding ranges to C++, and discussion inevitably reaches an impasse when
it gets to this particular matter.
I personally think we should and am amazed that we made it so far
without that primitive. However, unlike others, I don't think it's an
essential matter. Some C++ people tend to be apprehensive when they
figure they can do something with iterators that's not doable with ranges.
Andrei