c++ - 在 map 中存储标准 map

标签 c++ map insert std

我必须将 std::map 作为值存储在 std::map 中

std::map< std::string, std::map<std::string, std::string> > someStorage;

如何插入第二个(内部) map ?我试过了:

someStorage.insert( std::make_pair("key", std::make_pair("key2", "value2")) );

但这会引发很多错误。怎么了?

最佳答案

试试:

std::map< std::string, std::map<std::string, std::string> > someStorage;

someStorage["Hi"]["This Is Layer Two"] = "Value";

关于c++ - 在 map 中存储标准 map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4479017/

相关文章:

c++ - 如何在 opengl 中计算给定 3D 点及其 2D 屏幕位置的投影/模型 View 矩阵

c++ - 如何在类中全部内嵌数据结构模板(同一 .h 文件)

c++ - 如何在 Qt 中更有效地将标志传递给此函数?

scala - 线程安全地变换可变映射中的值

Java:并发递增计数器的映射

php - 错误 : check the manual [. ..] MySQL 服务器版本,以便在 ' 附近使用正确的语法

java - 是否可以使用 LWJGL 将 C++ OpenGL 代码与 Java 混合?

python - 如何将函数应用于列表的元素?

mysql - 将存储过程的结果插入现有表中

algorithm - 动态最小生成树