fork download
  1. #include <map>
  2. #include <memory>
  3. #include <string>
  4. //#include <boost/variant.hpp> ??? Guess Ideone doesn't have boost::variant?
  5.  
  6. struct BoostVariantFake
  7. {
  8. int blah;
  9. };
  10.  
  11. struct Data;
  12.  
  13. typedef std::map<std::string, std::unique_ptr<Data> > ConfigMap;
  14.  
  15. typedef BoostVariantFake ConfigValueTypes;
  16. //typedef boost::variant<int, float> ConfigValueTypes;
  17.  
  18. struct Data
  19. {
  20. ConfigValueTypes value;
  21. ConfigMap map;
  22. };
  23.  
  24. int main()
  25. {
  26. ConfigMap myMap;
  27. myMap["test"] = std::unique_ptr<Data>(new Data);
  28. myMap["test"]->value.blah = 357;
  29. myMap["test"]->map["example"] = std::unique_ptr<Data>(new Data);
  30.  
  31.  
  32. return 0;
  33. }
Success #stdin #stdout 0s 3028KB
stdin
Standard input is empty
stdout
Standard output is empty