On Thu, Jun 7, 2012 at 9:45 AM, Robert Ramey
Brian Budge wrote:
On Jun 6, 2012 9:43 PM, "Robert Ramey"
wrote: The case I am specifically thinking about is a pool allocator where when the shared_ptr destructor is called, it invokes the deleter on the pointer, returning the object to th pool. In the MPI case, a unique pool exists on each node.
right. I don't see any problem with the custom deleter.. If a custom deleter is specified for a shared pointer, I would expect it works as it always does.
Well, shared_ptr is not templatized on the custom deleter. It stores
it in a magical way under the hood. The deleter is accessed through
this standalone function:
template
More of a problem is the allocator. Allocation is currently a detail in the serialization library. As such, I'm not sure how easy to override it would be. On the other hand, since the STL collections have an allocator parameter, it might be that this is already addressed automatically by the serialization library. This would require more research into how the library allocates new object. I realize I wrote this code, but it was a number of years ago and I don't remember how it works.
Okay, fair enough :) What I want might actually be even simpler than
what I said. I essentially want to be able to pass contextual data
along the entire deserialization process. With
struct Bar {
Foo *foo;
int numFoo;
};
This could enable changing something like
template <class Archive>
void load(Archive &ar, Bar &b, const unsigned int version) {
ar >> b.numFoo;
b.foo = new Foo[b.numFoo];
ar.load_binary(b.foo, b.numFoo * sizeof(Foo));
}
to
template