lundi 4 septembre 2017

C++ no matching function for call

struct json_node;
using json_node_ptr = std::shared_ptr<json_node>;

struct json_node
{
    int id;
    std::vector<json_node_ptr> children;

    json_node(int _id)
        : id{ _id }
    {
    }
};

void to_json(anamespace::json& j, const json_node_ptr& node)
{
    j = ID;
    if (!node->children.empty()) {
        j.push_back( {"children", node->children} );
    }
}

I am getting the following error. How do I resolve this? What is the problem behind it?

Any easy workaround? It is not easy to change client library.

error: no matching function for call to ‘basic_json<>::push_back(<brace-enclosed initializer list>)’
             j.push_back( {"children", node->children} );

Aucun commentaire:

Enregistrer un commentaire