I have a class like this
template <typename T, typename Policy>
AutoObjectRelease {
public:
AutoObjectRelease(T& obj):obj_(obj){}
~AutoObjectRelease(){ Policy::Release(obj_); }
private:
T& obj_;
}
I wonder how one would you name this class, as it seems to me this could be quite a common pattern. I also wonder in which other situations you would use such a class. In my case I use the singleton object only sporadically and I wanted to make sure it doesn't remain loaded for the duration of the application. What are your thoughts on this ? Another idea would be to make the singleton object reference counted, but don't know exactly what would be the benefits for a singleton object - it might only complicate the implementation (need to make it thread safe also)