|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2003-10-30 14:37:58
"Peter Dimov" <pdimov_at_[hidden]> writes:
>> 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.
>
> Have you looked at the signature of std::nth_element? ;-)
That was the first thing I looked up, and why I didn't mention this
example ;-)
My sense of this is that C++ makes counting from 1 simply
incovenient. If you want to make an array of pointers to each
occurrence of a substring, and the search algorithm counts from 1,
you either have to add 1 to the array index or subtract one from the
ordinal.
After thinking about this problem, I see little use for the algorithm
in question which doesn't involve finding *each* occurrence starting
from the first. There's a much simpler way to do that using
std::find() and iterators. Maybe this one should just be stripped if
we can't agree on what it should mean.
-- Dave Abrahams 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