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,508 of 33,346   
   Martin B. to Dave Abrahams   
   Re: Will a const object be moved on retu   
   30 Sep 11 11:12:14   
   
   From: 0xCDCDCDCD@gmx.at   
      
   On 30.09.2011 10:03, Dave Abrahams wrote:   
   > on Thu Sep 29 2011, Howard Hinnant  wrote:   
   >   
   >> On Sep 29, 2:02 pm, "Martin B."<0xCDCDC...@gmx.at>  wrote:   
   >>> 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).   
   >>   
   >> I think moving from const, even from within a function-local, will   
   >> lead to more complicated, more confusion, than is worth the benefit.   
   >> Right now the rules are sufficiently simple that almost all cases just   
   >> work.  The returned-from local is typically not const.  And if it is,   
   >> just make it non-const and you're good to go.  The benefit of moving   
   >> from const is low, the cost (in teachability, language complexity) is   
   >> not.   
   >   
   > I'm not sure I agree.  Why do you think this has high cost to   
   > teachability?  It's consistent with the rationale for allowing an   
   > about-to-be-destroyed object to be moved, so I'd say it fits right in.   
   >   
   > My two concerns are:   
   >   
   > 1) it fiddles with the rules for move semantics, and they have not   
   >     proven to be all that easy to fiddle with without breaking something   
   >   
   > 2) it might break existing code.   
   >   
      
   I don't know about (2), but (1) is certainly a point.   
      
   Note how I'm *not* crying how this should have been in the C++11 std and   
   how could they miss this bla bla bla :-)   
      
   However, I think it is a very interesting point to keep in the backlog   
   until some confidence wrt. the current move rules has been reached.   
      
   cheers,   
   Martin   
      
      
   --   
         [ 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