This may seem odd, but I'll try to rationalize it. I currently use boost.object_pool extensively in conjunction with shared_ptr, and recently I encountered a situation that I need to take snapshots of current program states, in order to make functionality like full-scale replay/rollback/fast-forward.
So I am not trying to clone a object pool to use elsewhere, that won't work obviously because even if I am allowed to do so by boost.pool's interface (which I am not), there will be no valid pointers pointing to chunks in that newly cloned pool and it would just be pointless. But my use case here is I want to "paste" it back into the original pool if there's replay/rollback needs.
I certainly can just copy and clone all states, objects, and sub-states, sub-objects and subsub... manually and then pack them into a snapshot, and hope everything will go right, but that is error-prone given the complexity the project has already got, and it's gotta be a lot slower than if I can just copy the memory directly. Using Command pattern (or the like) to achieve undo-redo is pretty out of the question as well because undo-redo mechanism is not my intention.
I was just wondering if I do the project from scratch again using a die-hard traditional-C way, and a simple memcpy(snapshot, all_states, size) call would do almost all the work.
Is there any other option I am still missing? Is there any boost.object_pool like implementation that allow you to clone the underlying memory area? Is intrusively hacking boost.object_pool a plausible option considering the situation?