fork download
  1. namespace JSON
  2. {
  3. template <typename Tag> struct Literal { };
  4.  
  5. typedef Literal<struct tag_undefined> Undefined;
  6. typedef Literal<struct tag_false> False;
  7. typedef Literal<struct tag_null> Null;
  8. typedef Literal<struct tag_true> True;
  9.  
  10. struct Object;
  11. struct Array;
  12.  
  13. struct String {
  14. std::wstring value;
  15. bool operator==(String const& s) const { return value == s.value; }
  16. };
  17. }
  18.  
  19. namespace std
  20. {
  21. template <> struct hash<JSON::String>
  22. {
  23. size_t operator()(JSON::String const& s) const {
  24. static std::hash<std::wstring> _hash;
  25. return _hash(s.value);
  26. }
  27. };
  28. }
  29.  
  30. namespace JSON
  31. {
  32. struct Number { double value; };
  33.  
  34. typedef boost::variant<
  35. Undefined, // not legal as a JSON result
  36. False,
  37. Null,
  38. True,
  39. boost::recursive_wrapper<Object>,
  40. boost::recursive_wrapper<Array>,
  41. String,
  42. Number
  43. > Value;
  44.  
  45. struct Object
  46. {
  47. typedef std::unordered_map<String, Value> values_t;
  48. values_t values;
  49. };
  50.  
  51. struct Array
  52. {
  53. typedef std::deque<Value> values_t;
  54. values_t values;
  55. };
  56. }
  57.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty