home bbs files messages ]

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 32,270 of 33,346   
   Seungbeom Kim to Andy Lutomirski   
   Re: Placement new myself   
   10 May 12 11:37:38   
   
   From: musiphil@bawi.org   
      
   On 2012-05-08 11:31, Andy Lutomirski wrote:   
   > On 05/07/2012 07:41 PM, nroberts wrote:   
   >>   
   >> foo f = foo();   
   >>   
   >> new (&f) foo(f);   
   >>   
   >> As I understand it, this will try to recreate f on top of itself with   
   >> itself.   
   >   
   > It looks rather similar to this:   
   >   
   > #include    
   >   
   > int main()   
   > {   
   >    std::string x(x);   
   >    return 0;   
   > }   
      
   [I don't think you claimed the cases were the same, but anyway...]   
   The two cases are different. The emphasis for the OP's case is on   
   overwriting the storage for an already-existing object, since it's   
   perfectly fine to read from an already-existing object. The emphasis   
   for your case should be on reading from a not-yet-constructed object.   
      
   'T t(t);' in general could be defined or undefined, depending on what   
   the matching constructor does: it can use the argument only in a very   
   limited way, such as taking the address.   
      
   --   
   Seungbeom Kim   
      
      
         [ 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