Boost logo

Boost :

From: Rob Stewart (stewart_at_[hidden])
Date: 2003-10-30 12:33:44


From: Daniel Spangenberg <dsp_at_[hidden]>
> Rob Stewart schrieb:
>
> > Because s[0] isn't the 0th element; it's the first. As I said,
> > we use ordinals to refer to things like this. Addressing an
> > element uses an index, and indexes start at zero. "nth"
> > explicitly refers to ordinals, and there's no 0th; you start with
> > 1st, so find_nth() should reasonably start numbering from one.
> >
> > > You can think of find_nth as indexing into a view onto the matching
> > > substrings of s if you want.
>
> You you are right, but 0th is consistent to the naming of the std algorithm
> nth_element.

I don't agree with std::nth_element() taking zero to mean first,
but it's in the Standard. That makes it a solid precedent.

std::nth_element() views an iterator range as sorted and
indexes that sorted range. That's not unlike the defense of
find_nth() viewing a "string" as a set of substring matches and
indexing those. The analogy isn't perfect, but, sadly, it's
pretty convincing.

-- 
Rob Stewart                           stewart_at_[hidden]
Software Engineer                     http://www.sig.com
Susquehanna International Group, LLP  using std::disclaimer;

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