<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 14, 2014, at 11:26 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Nov 13, 2014 at 2:20 PM, Argyrios Kyrtzidis <span dir="ltr" class=""><<a href="mailto:akyrtzi@gmail.com" target="_blank" class="">akyrtzi@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><span class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Nov 13, 2014, at 11:25 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank" class="">dblaikie@gmail.com</a>> wrote:</div><br class=""><div class=""><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important" class="">I'd generally prefer conditional ownership over shared ownership if possible - it's a narrower contract & I can still think about where the single owner is.</span></div></blockquote></div><br class=""></span><div class="">I’m not so sure. With unique_ptr and shared_ptr you know exactly what is the ownership, without needing to know where it came from, it is very clear.</div></div></blockquote><div class=""><br class=""></div><div class="">Except that won't be true here - in at least some of these cases of conditional ownership, at the point where we enter into this arrangement we may not have ownership of the thing at all (it may've been passed down through several levels of non-owning, then we're calling into an API that has conditional ownership - or it may be a concrete object (stack or global) that cannot be shared) - if we used shared_ptr we could lie about it by creating a shared_ptr with a null deleter, which in some ways restricts the weirdness to where it's happening, but could be more confusing to developers rather than less (hey, I had this shared_ptr and somehow the object was destroyed - how could that ever happen? At least if it's conditional ownership they'll have a chance to realize that someone else is failing to live up to their side of the bargain)</div></div></div></div></div></blockquote><div><br class=""></div><div>I agree that lying with shared_ptr is bad; I’m advocating that we refactor the API and callers chain to use a real shared_ptr unless there is a strong reason not to.</div><div>If there is some rare ugly part that this is not possible we could debate it specifically and we may just live with the ugliness, but I’d prefer that we don’t make such unclear owning semantics easier to propagate.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">With conditional ownership I will have to hunt around in the codebase and find the trail between different code paths for where the pointer came from, so that I know who owns it and in what conditions.</div></div></blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></body></html>