
Alexander Terekhov wrote:
John Torjo wrote: [...]
// here - you need InterlockedCompareExchange // to realize that refcount is 0 (zero) shared_ptr<test> p3 = weak.lock();
lock() calls InterlockedCompareExchange (too bad it's fully fenced) if refcount isn't 0. Again, it can't see "false" zero.
of course - with the change I suggested ;) I wanted to say that the original implementation (http://www.pdimov.com/cpp/shared_count_x86_exp2.hpp) has a bug. Take a look at it please. Best, John -- John Torjo -- john@torjo.com Contributing editor, C/C++ Users Journal -- "Win32 GUI Generics" -- generics & GUI do mix, after all -- http://www.torjo.com/win32gui/ -- v1.4 - save_dlg - true binding of your data to UI controls! + easily add validation rules (win32gui/examples/smart_dlg)