In some cases, I wanted to have some kind of smart pointer based on time, for example, to cache some bulky object, but release it automatically after a certain time if it is not used. When the pointer touches (dereferenced), the countdown is restarted, and you can also stop the countdown if you need to “lock” the object alive for the duration of the calculation. Sort of:
timed_ptr<Type,30> p = new Type(); \\object is deleted after 30 seconds, and pointer set to a checkable 'null' state ... p.stop_count_down();
Is there any of this type in boost or in another library?
source share