Boost logo

Boost :

From: David Bradley (dbradley_at_[hidden])
Date: 2003-02-05 18:37:19

Peter Dimov wrote:

>How do you write a factory function that doesn't pass a smart pointer across
>library boundaries?
I guess it depends on what you're defining as library. I'm thinking of
things like DLL's and Unix style shared libraries as opposed to staticly
linked libraries. In these types of libraries you can't assume the
allocation routines are the same, and calling delete on a pointer that
was new'd within the library is a dangerous practice. This is really up
to the library implementor, though. What this means is that often
library implementors often provide secondary allocators/deallocators for
users to call instead of delete to destroy an object. From what I can
tell, since smart_ptr has no traits, there's no way for library
implementors to deal with this scenario, other than to abandon smart
pointers and use raw pointers across library bounders, or use a policy
based system that would allow them more control.

David Bradley

Boost list run by bdawes at, gregod at, cpdaniel at, john at