Hi, of course, in my opinion pool has to manage objects life time. However sharing objects with pool owner by shared ptr seems to be a good idea, because pool still manages objects life time. You are correct, the objects given to the user are still controlled by
michele.caini@gmail.com wrote: the pool but by passing the shared_ptr to the user the pool only has to worry about those item in its direct control. The downside to passing raw pointers to the user is the pool then has to keep track of which objects it has passed to the user and which objects are still available. This is an extra level detail that the shared_ptr allows us to avoid.
Using shared pointer also inside pool solves the problem, maybe. It is correct? I wasn't able to use the shared_ptr inside the pool. When creating the shared_ptr, the destructor function expects to call a function using the raw pointer. So the pool stores raw pointers but passes them to the user in a shared_ptr.
Ryan