Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do C++17 structured bindings not use { }?

I found the original proposal for *C++ structured bindings here. It proposes a way to easily bind multiple return values, i.e.:

auto {a, b} = minmax(data); 

But now I see that everyone points to the C++17/C++1z proposal syntax of

auto [a, b] = minmax(data); 

Now that I learned "lists are written { like, this }" there comes a new list-syntax? Why? What is the problem with curly braces here?

like image 399
towi Avatar asked Oct 30 '16 19:10

towi


1 Answers

This is still under debate. It's difficult to be certain which syntax will be least confusing given how many uses there are for [] and {} already.

There's also the risk that "least confusing" and "easiest to parse" will be in conflict.

like image 163
Jon Chesterfield Avatar answered Oct 23 '22 01:10

Jon Chesterfield