Using shared_ptr across shared library boundary
Is there any problem with using shared_ptr and passing an instance of it to a function in another shared library, such as a DLL under Windows ? Does the reference count get updated correctly when the copy is passed to a DLL function, so that when the last shared_ptr in either the original module or the DLL goers out of scope, the actual pointer is correctly deleted ? If this is not the case, that shared_ptr works correctly across DLL boundaries in the manner described, does instantiating and exporting shared_ptr template instances from the DLL to the module using the DLL solve the problem ?
"Edward Diener" <eddielee@tropicsoft.com> writes:
Is there any problem with using shared_ptr and passing an instance of it to a function in another shared library, such as a DLL under Windows ?
Works beautifully, even if the two DLLs are using different heaps.
Does the reference count get updated correctly when the copy is passed to a DLL function, so that when the last shared_ptr in either the original module or the DLL goers out of scope, the actual pointer is correctly deleted ?
Yep. -- Dave Abrahams Boost Consulting www.boost-consulting.com
"David Abrahams" <dave@boost-consulting.com> wrote in message news:u1xnzkubx.fsf@boost-consulting.com...
"Edward Diener" <eddielee@tropicsoft.com> writes:
Is there any problem with using shared_ptr and passing an instance of it to a function in another shared library, such as a DLL under Windows ?
Works beautifully, even if the two DLLs are using different heaps.
Does the reference count get updated correctly when the copy is passed to a DLL function, so that when the last shared_ptr in either the original module or the DLL goers out of scope, the actual pointer is correctly deleted ?
Yep.
Great to hear. Thanks !
participants (2)
-
David Abrahams
-
Edward Diener