Thomas Tutone wrote:
>> Thomas Tutone wrote:
>>> Alien wrote:
>>>
>>>
>>>> npos is defined as -1, in both SGI and VS.
>>>> So npos+1=0?
>>>> I remember that I read a book saying that npos+1==npos.
>>> The value of npos is implementation defined. On many platforms it is
>>> -1, but there is no requirement that that be the case. So don't rely
>>> on it.
>
> Alien wrote:
>> So, it's not defined in the standard?
>
> Kai-Uwe Bux has proven me wrong. It's defined in std::basic_string as
> const size_type npos = -1;
>
> I would have sworn Jossutis said it was implementation-defined.
>
He should have been right, except that it was originaly unspecified, not
implementation defined. Its purpose was to provide a sentinel value,
nothing more. Somehow unspecified got changed to -1, and that's led far
too many people to write code based on that particular value.
--
-- Pete
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." For more information about this book, see
www.petebecker.com/tr1book.