Reputation: 3375
I have a C++ program with a reference-counting smart pointer class. This class works by mapping pointers to reference counts in a static map:
map<ValueIntern*,unsigned int>& ValueRetainMapGetter(){
static map<ValueIntern*,unsigned int> m;
return m;
}
The issue that I've been having is that some static variables which I have are being deallocated after the reference map has been deallocated.
My question is: how can I control the order in which the static variables are deallocated so that the map is deallocated after all of the references.
Upvotes: 1
Views: 443
Reputation: 23217
I'd recommend using boost::shared_ptr
(or std::tr1::shared_ptr
if it's in your tool chain) instead of rolling your own.
Upvotes: 2