Are nested structured bindings possible?

前端 未结 2 1388
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-07 16:21

Assume I have an object of type

std::map> data;

Is it possible to access the element types

相关标签:
2条回答
  • 2021-01-07 16:29

    No, it is not possible.

    I distinctly remember reading somewhere that nested structured bindings are not allowed for C++17, but they are considering allowing it in a future standard. Can't find the source though.

    0 讨论(0)
  • 2021-01-07 16:30

    No, they aren't possible; but this is:

    for (auto&& [key, value] : data) {
      auto&& [my_int, my_float] = value;
    }
    

    which is close at least.

    0 讨论(0)
提交回复
热议问题