嵌套结构化绑定是否可能? [英] Are nested structured bindings possible?
本文介绍了嵌套结构化绑定是否可能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有一个对象类型
std::map<std::string, std::tuple<int, float>> data;
是否有可能以嵌套方式访问元素类型(即,在range循环中使用)像这样
Is it possible to access the element types in a nested way (i.e. when used in ranged for loop) like this
for (auto [str, [my_int, my_float]] : data) /* do something */
推荐答案
不行,不可能。
我清楚地记得在某处读到C ++ 17不允许嵌套结构化绑定,但是他们正在考虑在将来的标准中允许它。虽然找不到源。
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.
这篇关于嵌套结构化绑定是否可能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文