Closed GoogleCodeExporter closed 8 years ago
The current implementation of Value and Document (and even the rest of the
library) are not designed for run-time polymorphism. Therefore, the above code
example could be seen as user error.
I agree that this may be surprising and should be guarded against, e.g. by
having Document inheriting privately from Value and exposing only the allowed
interface (but disallowing the pointer conversion). Such a change can still
break existing code, though.
On the other hand, adding virtual functions (like a destrcutor) to Value will
break the existing implementation in various places. The in-place
onstruction/destruction used for the move semantics of Value will no longer
work in the presence of virtual functions (or at least cause significantly
undefined behaviour in C++).
My 2¢,
Philipp
Original comment by philipp....@gmail.com
on 28 May 2014 at 11:30
[deleted comment]
Agree with Philipp.
Adding virtual functions in general would also hurt performance, compromise the
"rapid" part of it.
Just to read data from json, the way I understand it, only one 'delete' is
required, that is of the whole document. Documentation should probably outrule
deletion of the document in any other way except with
rapidjson::Document::~Document()
I tested rapidjson in such read-only usage model for the memory leaks, and
couldn't find any leaks.
Original comment by yuriv...@gmail.com
on 6 Jun 2014 at 1:42
Original comment by milo...@gmail.com
on 20 Jun 2014 at 11:19
Original issue reported on code.google.com by
rous...@chromium.org
on 19 May 2014 at 8:00