为什么C ++ 17结构化绑定不使用{}? [英] Why do C++17 structured bindings not use { }?

查看:90
本文介绍了为什么C ++ 17结构化绑定不使用{}?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在此处找到了有关* C ++结构化绑定的原始建议。一个>。它提出了一种轻松绑定多个返回值的方法,即:

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);

但是现在我看到每个人都指向C ++ 17 / C ++ 1z建议语法

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?

推荐答案

这仍在争论中。考虑到[]和{}已经使用了多少种语法,很难确定哪种语法最容易混淆。

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.

这篇关于为什么C ++ 17结构化绑定不使用{}?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆