C++ Logo

std-proposals

Advanced search

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

From: David wang <wangjufan_at_[hidden]>
Date: Sun, 12 May 2024 10:18:59 +0800
On Saturday, May 11, 2024 09:00 Oliver Sch?dlich via Std-
Proposals 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;

The automatic type deduction reduces the verbosity of code which makes it
easier to work with structured data. If you really like it, you can make
use of std::tie.

Received on 2024-05-12 02:19:11