<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Mar 28, 2018, at 4:36 PM, John McCall <<a href="mailto:rjmccall@apple.com" class="">rjmccall@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Mar 28, 2018, at 4:48 PM, James Gregurich <<a href="mailto:bayoubengalml@mac.com" class="">bayoubengalml@mac.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Mar 28, 2018, at 3:21 PM, John McCall <<a href="mailto:rjmccall@apple.com" class="">rjmccall@apple.com</a>> wrote:</div><div class=""><br class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">I absolutely understand the benefits of having smart pointer types that automatically manage your retains and releases.  I'm not arguing that you shoudn't use smart pointers.  I don't know why you specifically want to call your smart pointers std::shared_ptr and std::weak_ptr, though, because you are just creating problems for yourself.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Why should one re-invent the wheel? the std classes work great in the non-arc mode.</div></div></div></div></blockquote><div class=""><br class=""></div><div class="">I don't understand how.  In non-ARC mode, std::shared_ptr will not retain the value it holds or release it when the shared_ptr is destroyed.  It will *compile*, of course, and probably run fine in many cases because of the autorelease pool.</div></div></div></div></blockquote><div><br class=""></div><div><br class=""></div><div>you supply a custom deallocator that calls release when appropriate.</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255);"><span class="">template<class _Tp></span><br class=""><span class="">class _LIBCPP_TEMPLATE_VIS weak_ptr</span><br class=""><span class="">{</span><br class=""><span class="">public:</span><br class=""><span class="">    typedef _Tp element_type;</span><br class=""><span class="">private:</span><br class=""><br class=""><br class=""><br class=""><font color="#251fff" class=""><span class="">#if </span>defined(__clang__) && <span class="">defined(__OBJC__) && __has_feature(objc_arc)</span></font></div><div class="" style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);"><font color="#251fff" class=""><span class="" style="font-family: Helvetica; font-size: 12px;">    element_type __unsafe_unretained * __ptr_;</span><br class="" style="font-family: Helvetica; font-size: 12px;"><span class="" style="font-family: Helvetica; font-size: 12px;">#else</span></font><br class="" style="font-family: Helvetica; font-size: 12px;"><span class="" style="font-family: Helvetica; font-size: 12px;">    element_type*        __ptr_;</span><br class="" style="font-family: Helvetica; font-size: 12px;"><span class="" style="font-family: Helvetica; font-size: 12px;"><font color="#271fff" class="">#endif</font></span><br class="" style="font-family: Helvetica; font-size: 12px;"><br class="" style="font-family: Helvetica; font-size: 12px;"><span class="" style="font-family: Helvetica; font-size: 12px;">    __shared_weak_count* __cntrl_;</span></div></div></div></div></blockquote><div class=""><br class=""></div>This would break std::weak_ptr for all non-ObjC element types.</div><div class=""><br class=""></div></div></div></blockquote><br class=""></div><div>doh!  you're right. slight hole in my thinking. Its what I get for speaking off the top of my head.  Let me actually go prototype the changes in a real project so I don't look stupid again.  :) </div><div><br class=""></div><div><br class=""></div><div><br class=""></div><div><br class=""></div><div><br class=""></div><br class=""></body></html>