Date: Fri, 25 Aug 2023 20:05:45 +0100
On Fri, 25 Aug 2023, 19:18 Lénárd Szolnoki via Std-Proposals, <
std-proposals_at_[hidden]> wrote:
> I don't think std::pair allows the members to be potentially overlapping,
> which means that programs that memcpy over first and second are valid now.
> So this would be a breaking change for pair.
>
Yes, it would definitely be a breaking change. I don't think the benefit
outweighs the cost.
It isn't allowed today. If we required it in the next standard, it would be
a breaking change and prevent mixing C++26 code with any earlier version.
If it was optional in the next standard, you couldn't actually rely on it,
and in reality some implementations would never implement it.
> I think tuple allows this.
>
Yes, the layout of members in tuple has never been specified.
Why can't you just use std::tuple<T,U> for a compressed pair? I think it
works with all current implementations, and is allowed for all future ones.
std-proposals_at_[hidden]> wrote:
> I don't think std::pair allows the members to be potentially overlapping,
> which means that programs that memcpy over first and second are valid now.
> So this would be a breaking change for pair.
>
Yes, it would definitely be a breaking change. I don't think the benefit
outweighs the cost.
It isn't allowed today. If we required it in the next standard, it would be
a breaking change and prevent mixing C++26 code with any earlier version.
If it was optional in the next standard, you couldn't actually rely on it,
and in reality some implementations would never implement it.
> I think tuple allows this.
>
Yes, the layout of members in tuple has never been specified.
Why can't you just use std::tuple<T,U> for a compressed pair? I think it
works with all current implementations, and is allowed for all future ones.
Received on 2023-08-25 19:06:00