What are use cases for structured bindings?

前端 未结 4 1407
滥情空心
滥情空心 2020-12-05 13:24

C++17 standard introduces a new structured bindings feature, which was initially proposed in 2015 and whose syntactic appearance was widely discussed later.

Some use

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-05 14:21

    Can you provide some other, possibly less obvious use cases for structured bindings?

    They can be used to implement get for structs - see magic_get's automatically generated core17_generated.hpp. This is useful because it provides a primitive form of static reflection (e.g. iterate over all members of a struct).

提交回复
热议问题