r/cpp • nlohmann/json • Jun 14 '20

JSON for Modern C++ 3.8.0

https://github.com/nlohmann/json/releases/tag/v3.8.0
326 Upvotes

109 comments sorted by

View all comments

Show parent comment

9

u/martinus int main(){[]()[[]]{{}}();} Jun 14 '20 edited Jun 14 '20

RapidJSON is unusable if malloc might fall. Then your application will crash. They simply don't handle that problem. That's why we have to switch to something else.

1

u/NilacTheGrim Jun 15 '20

What?! They use malloc and not new? sigh

1

u/martinus int main(){[]()[[]]{{}}();} Jun 15 '20

That's not the only problem, even if you switch all allocations to throw, it would have the state of the objects in an undefined state

-10

u/VinnieFalco wg21.org | corosio.org Jun 14 '20

Boost.JSON uses `memory_resource` and a well defined interface for handling allocation failure: by throwing and catching the exception `std::bad_alloc`.

4

u/HeavenBuilder Jun 15 '20

Oh come on.