static ryml::Tree #198
Answered
by
biojppm
parihaaraka
asked this question in
Q&A
-
Hello. Could you please explain the tree's memory handling details in v.0.3? |
Beta Was this translation helpful? Give feedback.
Answered by
biojppm
Jan 21, 2022
Replies: 1 comment
-
Here's an example: // Using static trees may incur a static initialization order problem.
// This happens because a default-constructed tree will obtain
// the callbacks from the current global setting, which may
// not have been initialized due to undefined static initialization
// order:
//
//static ryml::Tree tree; // ERROR! depends on ryml::get_callbacks() which may not have been initialized.
//
// To work around the issue, declare static callbacks
// to explicitly initialize the static tree:
static ryml::Callbacks callbacks = {}; // use default callback members
static ryml::Tree tree(callbacks); // OK
// now you can use the tree just as normal:
ryml::parse_in_arena(R"(doe: "a deer, a female deer")", &tree);
CHECK(tree["doe"].val() == "a deer, a female deer"); I will add this example to the quickstart. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
biojppm
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's an example: