I use a std::unique_ptr
with a custom deleter as a value of a std::map
as follows:
#include <iostream>
#include <memory>
#include <map>
void deleter(int* p){
std::cout<<"Deleting..."<<std::endl;
delete p;
}
int main()
{
std::map<char, std::unique_ptr<int, void(*)(int*)>> a;
std::unique_ptr<int, void(*)(int*)> p{new int{3}, deleter};
a['k'] = std::move(p);
}
When inserting a value, I use std::move
, but it will not compile.
What am I doing wrong?
You see the errors following link.