我想定义一个地图,它将一个字符串作为关键字,但该值将是一个以字符串作为关键字的地图,但该值将会是一个地图类似的性质......,最终链中的最后一张地图将是从字符串到字符串的映射。C++:定义具有递归属性值的地图
我想实现标记的JSON数据结构的值。
为了说明,这里是我能想出的代码段:
typedef map<string, string> str2str;
typedef map<string, str2str> str2str2str;
...
typedef map<string, str2map_or_str> str2map_or_str;
是什么在C++中惯用的方法呢?
看看https://stackoverflow.com/questions/23601686/shorthand-syntax-for-c-map-in-map。也许这就是你要找的。 –
谢谢,但该解决方案似乎假定地图的已知水平。我不知道,它需要多少级别。 –