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

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to