Date: Tue, 9 Dec 2025 09:24:35 +0000
On Tue, 9 Dec 2025 at 09:20, Nikl Kelbon <kelbonage_at_[hidden]> wrote:
> > This is required to work even if the range overlaps with the vector.
>
> So, my general code must if constexpr (is_same_v<vector>) or what?
>
> Additionally, you really good with:
>
> vector x = ...;
>
> x.append_range(subrange(x.begin(), x.end()));
> "this is required to work even if range overlaps"
>
> But
>
> vector x = ...;
> x.reserve(x.size() * 10);
> x.insert(x.end(), x.begin(), x.end()); // undefined behavior
>
> Nice, really great interface
>
I was going to point out that append_range is explicit about appending to
the end, whereas insert(pos, first, last) has to handle the general case of
inserting anywhere, and that it complicates things to make a special case
for inserting at the end (when there is already a dedicated API for doing
that).
But I'm not going to bother engaging in this thread any more.
> > This is required to work even if the range overlaps with the vector.
>
> So, my general code must if constexpr (is_same_v<vector>) or what?
>
> Additionally, you really good with:
>
> vector x = ...;
>
> x.append_range(subrange(x.begin(), x.end()));
> "this is required to work even if range overlaps"
>
> But
>
> vector x = ...;
> x.reserve(x.size() * 10);
> x.insert(x.end(), x.begin(), x.end()); // undefined behavior
>
> Nice, really great interface
>
I was going to point out that append_range is explicit about appending to
the end, whereas insert(pos, first, last) has to handle the general case of
inserting anywhere, and that it complicates things to make a special case
for inserting at the end (when there is already a dedicated API for doing
that).
But I'm not going to bother engaging in this thread any more.
Received on 2025-12-09 09:24:52
