Re: vector.erase(iterator iter) will change "iter" or not?
In message
<c76ba343-355d-46ed-b028-3cd137425161@s13g2000prd.googlegroups.com>, Old
Wolf <oldwolf@inspire.net.nz> writes
>On Feb 22, 4:31 am, Richard Herring <junk@[127.0.0.1]> wrote:
>> In message <fpk2sg$5d...@news.datemas.de>, Victor Bazarov
>> >The iterator that refers to the removed element and all elements
>> >after the removed one are invalidated by that operation. IOW, the
>> >Standard makes no attempt to define what the 'iter' would point to
>> >after being erased.
>>
>> I wonder if the OP is confused because the iterator is passed by value
>> and therefore not modified? Obviously erase(iter) can't change its
>> _value_, but it certainly changes its _meaning_ - what it points to is
>> no longer valid.
>
>The value certainly is changed: previously it was
>well-defined and now it is indeterminate!
Its value has become singular, certainly, but that's because the set of
singular values has changed, not because the iterator has.
> It doesn't
>point anywhere; it's nonsensical to say that what
>it points to is not valid.
If it doesn't point anywhere, it points nowhere. "nowhere" looks pretty
invalid to me.
> Perhaps you mean to say
>that the representation isn't changed;
Perhaps.
--
Richard Herring
|