pankaj kushwaha pankaj kushwaha - 1 year ago 83
C++ Question

unable to insert data in a stl map of map of map

I have following map declaration :

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

I tried inserting data in following way :

m.insert({ "HARDWARE\\DESCRIPTION\\System\\BIOS", { "REG_SZ", { "SystemSKU", "SystemSKU" } } });

but its not working , what is correct syntax to insert data?

Answer Source

If you cannot get it to work with initializer lists you could use the classical way:

m["HARDWARE\\DESCRIPTION\\System\\BIOS"]["REG_SZ"]["SystemSKU"] = "SystemSKU";

Hope this helps.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download