Re: [Boost-users] Boost shared pointers and MSVC++ 6.0
-----Original Message----- No, this isn't normal. shared_ptr should work even if you don't do (1) or (2), with one exception: the plugin that created a shared_ptr needs to be present in memory when the last copy of this shared_ptr is destroyed (because the creator plugin contains the destructor code.) So if you don't unload plugins dynamically, it _should_ work. If it doesn't, try to isolate a simple example for us to investigate.
How will it work if the main program is linked against the multi-threaded dll and some other library the single-threaded, but the object that was created in the MT-linked dll is deleted by the one in the ST-dll? Wouldn't different deletes be called?
Sohail Somani wrote:
No, this isn't normal. shared_ptr should work even if you don't do (1) or (2), with one exception: the plugin that created a shared_ptr needs to be present in memory when the last copy of this shared_ptr is destroyed (because the creator plugin contains the destructor code.) So if you don't unload plugins dynamically, it _should_ work. If it doesn't, try to isolate a simple example for us to investigate.
How will it work if the main program is linked against the multi-threaded dll and some other library the single-threaded, but the object that was created in the MT-linked dll is deleted by the one in the ST-dll?
The object is always deleted by the same library that created the shared_ptr. This is done by instantiating an appropriate deleter at construction time. You can defeat this by creating the object in library A and the shared_ptr in library B, of course. Mixing single- and multithreaded libraries might be a problem for other reasons, but even that should work on Windows with Boost 1.33 with the default configuration.
participants (2)
-
Peter Dimov
-
Sohail Somani