Skip to content

static ryml::Tree #198

Answered by biojppm
parihaaraka asked this question in Q&A
Discussion options

You must be logged in to vote

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 ju…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by biojppm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants