Re: vector.erase(iterator iter) will change "iter" or not?
On Feb 23, 6:40 am, James Kanze <james.ka...@gmail.com> wrote:
> unsigned char before[ sizeof( std::vector<int>::iterator ] ;
> memcpy( before, &iter, sizeof( std::vector<int>::iterator ) ) ;
> v.erase( iter ) ;
> memcmp( before, &iter, sizeof( std::vector<int>::iterator ) ) ;
>
> the memcmp will return a value not equal to 0.
How does that work? I agree that it's legal, but I wouldn't
expect it anywhere except the DS9000; it seems that the
implementation, when faced with vector::erase, would have
to go out of its way to go and change bits in the original
'iter' that the parameter to vector::erase was copied from.
> And trying to use the iterator will cause a core dump.
To be expected when using indeterminate 'values'.
|