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 31,503 of 33,346   
   =?ISO-8859-1?Q?Daniel_Kr=FCgler?= to All   
   Re: Will a const object be moved on retu   
   29 Sep 11 16:40:23   
   
   From: daniel.kruegler@googlemail.com   
      
   Am 29.09.2011 20:02, schrieb Martin B.:   
   > Isn't this something that could be improved in a future version of the   
   > standard? C++ already considers a local l-value as an r-value on return,   
   > wouldn't it make sense to "ignore" the constness? After all, the object   
   > *is* gonna be destructed right away, and for it's dtor, the constness is   
   > irrelevant (or so I like to think).   
      
   This is an interesting idea and looks doable. For copyable types like   
   strings this would be purely an optimization advantage (but a reasonable   
   one, don't get me wrong here). Even more interesting is that this would   
   also work for automatic and const, but move-only objects, e.g. when   
   using std::unique_ptr as in the following example:   
      
   std::unique_ptr source() {   
     const std::unique_ptr p(...);   
     ... // Work on p, but forbid *all* mutating operations.   
     return p;   
   }   
      
   Greetings from Bremen,   
      
   Daniel Krügler   
      
      
   --   
         [ 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