Re: RFC - lifetime management
>> 1. More informative class and method names
>
>Well, the name heap makes me think of a certain kind of memory
>management system. Probably a name like Keepalive_bucket would
>be clearer?
Yes! There are probably even better names. Names might involve manual/garbage collection, owner, life time [synchronizer], delayed/synchronized destruction/or, respirator, reaper, .. well, probably getting a bit too creative here :) I'd love more suggestions/opinions though!
>> 5. Raw pointers can be handled more efficiently than shared_ptrs
>
>But think of it - if that pointed-to object is in use by some other
>means, it would be destroyed by the heap destructor nevertheless.
Creating a shared_ptr from a raw pointer has the same "problem". If users fail to realize this, they've misunderstood the whole point of the class.
>An (untested) wrapper class I would start with would be something like:
>
>class Keepalive: private boost::noncopyable {
> Std::vector< boost::shared_ptr<void> > v;
>public:
> template <typename T> void put(boost::shared_ptr<T> p) {
>v.push_back(p); };
> template <typename T> void put(std::auto_ptr<T>& p) {
>v.push_back(boost::shared_ptr<T>(p)); };
> template <typename T> void put(T *p) {
>v.push_back(boost::shared_ptr<T>(p)); };
>};
>
>Does that solve your needs?
Yes, this is basically what the implementation I'm using today I looks like. The question is if anybody else finds it useful.
Again - thanks for your input!
Johan