Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2006-02-03 19:23:27


Thorsten Ottosen wrote:
>
> Anyway, if the convention of range-based algorithms should
> be "always return [found,end)", it raises the question why we think
> this range is more imoprtant than [begin,found) (and some of the others).
>
> The natural answer is of course: it is not more important or more
> fundamental.
>
> Therefore it is natural to investigates means to return the slices you
> need. We have already seen that seperate slice functions cannot be
> always be safe unless they require the use of a temporary, thus
> defeating the much purpose of ranges.

This is a very interesting question, and one that I admit I haven't
given enough consideration. My reasoning for wanting find() to return
[found,end) is that it makes it easy to compose this algorithm with
another that continues searching in the remainder of the sequence. But
consider find_end() which finds the /last/ occurrence. Applying the same
reasoning, should it return [begin,found)? IMO that's a wrinkle that
would trip people up. What really is the guiding principle here?

No answers, just questions.

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk