C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Structured binding without type inference

From: Jan Schultke <janschultke_at_[hidden]>
Date: Sun, 12 May 2024 09:34:01 +0200
The proposed syntax is a bit misleading because the type is still a
std::pair, not an int. Something like what Tiago wrote would make sense,
where you can specify a type per bound name.

However, I don't think implicit conversions would be appropriate here, so
the rules would be different from a variable in the sense that you would
always need to specify the type exactly. That also makes this whole thing a
bit less powerful and useful though.

On Sat, May 11, 2024, 08:59 Oliver Schädlich via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> If all variables of a structured binding are the same I think structured
> binding without type inference would improve the readability.
>
> pair<int, int> pii;
> int &[a, b] = pii;
>
> Or:
>
> pair<int, char> pic;
> int [a, b] = pic;
>
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2024-05-12 07:34:18