<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 13, 2014 at 2:20 PM, Argyrios Kyrtzidis <span dir="ltr"><<a href="mailto:akyrtzi@gmail.com" target="_blank">akyrtzi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><span class=""><br><div><blockquote type="cite"><div>On Nov 13, 2014, at 11:25 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:</div><br><div><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">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></span><div>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><br></div><div>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><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>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></div></div>