I'm new to C++'s smart pointers and at some point in my code I need to have a shared pointer of an unordered_map. I realized that I can't initialize the shared_ptr in the following way:
typedef std::unordered_map<std::string, std::string> JsonDict;
std::shared_ptr<JsonDict> ret = std::make_shared<JsonDict>(new JsonDict);
This is the compile error I'm getting:
*Error C2664 'std::unordered_mapstd::string,std::string,std::hash<_Kty,std::equal_to<_Kty>,std::allocator<std::pair<const _Kty,_Ty>>>::unordered_map(const std::unordered_map<_Kty,_Ty,std::hash<_Kty>,std::equal_to<_Ty>,std::allocator<std::pair<const _Kty,_Ty>>> &)': cannot convert argument 1 from 'std::unordered_mapstd::string,std::string,std::hash<_Kty,std::equal_to<_Kty>,std::allocator<std::pair<const _Kty,_Ty>>> ' to 'const std::allocator<std::pair<const _Kty,_Ty>> &' *
I don't really understand why I'm getting this compile error.
Aucun commentaire:
Enregistrer un commentaire