On Wed, 16 Feb 2011 11:14:27 -0500, Andrej Mitrovic <andrej.mitrov...@gmail.com> wrote:

On 2/16/11, spir <denis.s...@gmail.com> wrote:

for any reason, I would prefere
     findBack(haystack, needle);
:-)

Or maybe find should have an extra parameter that decides if the
search begins from the beginning or the end of the range.

I just realized, this isn't possible in the general case. That is, given your original range [5, 1, 2, 3, 4, 5, 1], the only way to get [5, 1] is to use popFront.

Think about this. What are the basic operations of a bidirectional range? popFront and popBack. There is no way to search from the back, and then use that as the front end of the resulting range.

Essentially, the range API does not allow what you want unless you have a random-access range, and I don't even know if that can be generalized. The operation you are looking for is very different from what find does.

-Steve

Reply via email to