I will use std::map<int, A>
A is a class and I have to prevent shallow copy,
but there are many classes like A, so making a deep copy construct and operator is tiresome.
Since it seems that I don’t have to use copy constructor and copy assignment operator,
I decide not to use them.
To prevent some mistakes, I made UnCopyable class, which has private copy constuctor and copy assignment operator, and A inherited it.
However, there is one problem. std::map use a copy constructor.
I don’t want to save A‘s pointer in the map.
What’s the better solution?
You could use a smart pointer like
std::shared_ptror write a proxy class.E.g.:
or