On 12 May 2024 08:34:01 BST, Jan Schultke via Std-Proposals <std-proposals@lists.isocpp.org> wrote: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.Maybe you could specify a concept per element. auto [same_as<int> x, same_as<double> y] = ...
Discussions in the past have suggested using the return-type-requirement syntax from compound requires expressions for this.
auto [x -> same_as<int>, y ->
same_as<double>] = ...
Tom.
On Sat, May 11, 2024, 08:59 Oliver Schädlich via Std-Proposals < std-proposals@lists.isocpp.org> 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@lists.isocpp.org https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals