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

前端 未结 5 2200
轮回少年
轮回少年 2020-12-14 05:18

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


        
5条回答
  •  猫巷女王i
    2020-12-14 06:10

    The change from {} to [] occurred after Jacksonville and was made in response to comments from that meeting. This is detailed in p0144r2, which states: "because it is more visually distinct from the existing syntax for declaring multiple variables of the same type."

    It appears that the NB comments requesting a change to the original usage of {} did not increase consensus in the Nov 2016 meetings, leaving the [] usage intact. At least until the Spring meeting.

提交回复
热议问题