gpt4 book ai didi

c++ - "structural binding"上的提案在哪里?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:01:32 27 4
gpt4 key购买 nike

在下面C++ Going native video ,
提到了一种称为“结构绑定(bind)”的语言功能。

我曾经有过referred将这个概念称为“解构”(javascript 背景)。

该功能将允许用户捕获多个返回值,而无需使用 std::tie 或指定类型。

示例:

std::map<std::string,int> table;
auto { cursor, inserted } = table.insert({"hello",0});

我在哪里可以找到此提案并跟踪其进度?

最佳答案

您所指的提案是P0144R0: Structured Bindings . post-Kona mailing将这篇论文列为进化工作组。当前 Evolution Working Group(EWG) active issue list 中未涵盖Nicol Bolos 指出 EWG 事件问题列表尚未针对 Kona 进行更新。一旦它出现在 EWG 事件列表中,您就可以通过跟踪问题来跟踪提案。

有一些非常好的旅行报告,特别是 Botond Ballo's trip report鼓励进一步工作的提案 部分下涵盖此提案,它说:

A proposal for de-structuring initialization, that would allow writing auto {x, y, z} = expr; where the type of expr was a tuple-like object, whose elements would be bound to the variables x, y, and z (which this construct declares). “Tuple-like objects” include std::tuple, std::pair, std::array, and aggregate structures. The proposal lacked a mechanism to adapt a non-aggregate user-defined type to be “tuple-like” and work with this syntax; EWG’s feedback was that such a mechanism is important. Moreover, EWG recommended that the proposal be expanded to allow (optionally) specifying types for x, y, and z, instead of having their types be deduced.

我们可以转到 WG21 site 找到 WG21 session 邮件然后去papers section .

作为 T.C.注意还有一个竞争提案P0151R0: Proposal of Multi-Declarators其中说:

We propose a better approach for “Structured Bindings” as defined in P0144R0 where “better” is defined as terser, more ortogonal, more general, more expressive, less (parsingwise) ambiguous.

关于c++ - "structural binding"上的提案在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34111451/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com