sonic-cpp
sonic-cpp copied to clipboard
Proposal: friendly list initialization for document or node.
Now, initialization is complex as follows:
Document doc;
doc.SetObject();
doc.AddMember(key, value);
Can we use the c++11 initialization list:
Document doc { {"a", "b"}, {"c", false}, {"d", {1, 2, 3}}};
I don't think this is correct c++ syntax.
A typo has been fixed and C++11 has supported list initialization. However, the main issue is how to differentiate between object and array types. For a example, doc{"a", 1} may be Array["a", 1] and Object{"a", 1}.