I stopped while inserting a unique pointer into a std::unordered_map
.
when I looking for the answer I got a link : C++ inserting unique_ptr in map.
I tried that but it will not work for me. Here is my sample what I tried till now.
int main()
{
unordered_map<string,unique_ptr<char[]>> mymap;
string key = "ac";
char* ctr = "myvalue";
unique_ptr<char[]> value = make_unique<char[]>(100);
memcpy(value.get(), ctr,5);
mymap.insert_or_assign(key,std::move(value));
return 0;
}
Getting a compilation issue.