sonic-cpp icon indicating copy to clipboard operation
sonic-cpp copied to clipboard

Proposal: friendly list initialization for document or node.

Open liuq19 opened this issue 2 years ago • 2 comments

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}}};

liuq19 avatar Mar 17 '23 05:03 liuq19

I don't think this is correct c++ syntax.

xiegx94 avatar Mar 22 '23 11:03 xiegx94

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}.

liuq19 avatar Mar 28 '23 02:03 liuq19