fork download
  1. #include <iostream>
  2. #include <map>
  3. #include <string>
  4. #include <list>
  5.  
  6. using namespace std;
  7.  
  8.  
  9. int main()
  10. {
  11. struct myStruct { string name2; int aCnt; std::list<string> theItems; };
  12.  
  13. // Now I define a map
  14. std::map<string, myStruct> myMap;
  15.  
  16. // Now I want to add items to myMap.
  17. myMap["ONE"] = {"TEN", 3, {"p1","p2","p3"}}; // But this doesn't seem to work
  18.  
  19. // I know I could do something like
  20. myStruct myst;
  21. myst.name2 = "TEN";
  22. myst.aCnt = 3;
  23. myMap["ONE"] = myst;
  24.  
  25. return EXIT_SUCCESS;
  26. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
Standard output is empty