Improve relocation
Marc Glisse
marc.glisse@inria.fr
Thu Nov 22 18:45:00 GMT 2018
On Thu, 22 Nov 2018, Jonathan Wakely wrote:
>> "For __relocate_a_1, I should also test if copying, ++ and != are noexcept,
>> but I wanted to ask first because there might be restrictions on what
>> iterators are allowed to do, even if I didn't see them."
>
> I decided to postpone thinking about that :-)
>
> In general iterators can throw on those operations. But for container
> iterators copy construction of "a returned iterator" never throws. I
> think that means that copying a singular iterator is allowed to throw,
> but no container member functions ever return singular iterators.
>
> Increment and decrement could throw, but for our implementation they
> don't (and so far __relocate_a_1 is only used with pointers, or vector
> or deque iterators, right?) Since we know we're using valid iterator
> ranges (because we choose the begin and end iterators of the ranges
> being relocated) it should also be safe to assume we never increment a
> past-the-end iterator or anything else that might give an iterator a
> reasom to throw.
Indeed, I think currently we only use relocate with vector iterators, so
it is not urgent to fix this.
> Is that good enough, or do you want to make __relocate_a_1 general
> enough to work with arbitrary iterators?
Eventually yes, but now that I think about it, as long as relocation is a
private implementation detail, all uses are likely to be with standard
iterators that we control, so it may not matter.
So now I agree with the "postpone" decision, thanks.
--
Marc Glisse
More information about the Libstdc++
mailing list