Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c++.moderated    |    Moderated discussion of C++ superhackery    |    33,346 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 33,168 of 33,346    |
|    Greg Marr to All    |
|    Re: Does std::unique_ptr support self-re    |
|    12 Aug 13 10:48:09    |
      From: gregmmarr@googlemail.com              On Monday, August 12, 2013 10:30:12 AM UTC-4, SG wrote:       > I don't see why unique_ptr should support       >       > p.reset(p.get());       >       > reset is supposed to take a nullptr or pointer to an object that's not       > already owned by someone else. So, if you invoke reset with an address       > of some object that another (or the same) unique_ptr instance already       > owns, you did something wrong.              Ah, the *not already owned* was probably the part that I wasn't considering.       That makes it more obvious why the p.reset(p.release()) was proper but       p.reset(p.get()) wasn't.              Thanks.              > Can you come with with an example that relies on a self-reset-test but       > is not considered broken by others?              Given the above, probably not. I guess it was just the fact that something       that *seemed* to be allowed by the draft standard (yes Daniel, I realize that       it was still a draft at that point, but it was still a deliberate choice)       was changed to very bad undefined behavior. The requirement that p.reset()       take a *non-owned* pointer shows that it was already undefined behavior.                     --        [ See http://www.gotw.ca/resources/clcm.htm for info about ]        [ comp.lang.c++.moderated. First time posters: Do this! ]              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca