jeudi 24 septembre 2020

How can I fix this error 'no matching function for call'?

Given the following code:

    std::map<std::string, std::unique_ptr<Obj>> objs;
    std::string str;
    Obj obj;
    std::unique_ptr<Obj> objUniquePtr = std::unique_ptr<Obj>(new Obj(obj));
    objs.insert({ str, objUniquePtr });   <<<<<<<< ERROR

I get the following error:

no matching function for call to 'std::map<std::__cxx11::basic_string<char>, std::unique_ptr<Obj> >::insert(<brace-enclosed initializer list>)'

How can I fix this error?

Aucun commentaire:

Enregistrer un commentaire